首页 > 数据库技术 > 详细

导入sql文件到mysql容器中

时间:2020-05-08 00:33:10      阅读:92      评论:0      收藏:0      [点我收藏+]

导入sql文件到mysql容器中

 1. 在docker-compose文件中增加挂载路径./sqlfile,将sql文件映射进容器。

    volumes:

      - ./data/docker/mysql:/var/lib/mysql

      - ./mysql/:/docker-entrypoint-initdb.d/

      - ./conf/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf

      - ./sqlfile:/app/sqlfile

  或者可以使用docker cp 的方式。

2. 进入容器内部,导入sql文件到指定数据库。

$ docker exec -it 54e61c8c4846 bash

#mysql -uroot -proot

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| apigateway-ai      |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

5 rows in set (0.00 sec)

mysql> use apigateway-ai;

mysql> source /app/sqlfile/ai_api_profile.sql;

mysql> show tables;

+-------------------------+

| Tables_in_apigateway-ai |

+-------------------------+

| ai_api_profile          |

+-------------------------+

1 row in set (0.00 sec)

结束。

导入sql文件到mysql容器中

原文:https://www.cnblogs.com/liusingbon/p/12842903.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!