1、执行命令:docker exec -i wshop-mysql mysql -uroot -proot wshop_store < wshop_store.sql ,报错:mysql: [Warning] Using a password on the command line interface can be insecure.。如图1
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker exec -i wshop-mysql mysql -uroot -proot wshop_store < wshop_store.sql mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump: [Warning] Using a password on the command line interface can be insec' at line 1
2、进入 MySQL 容器,查看数据库 wshop_store,显示所有表,响应:Empty set (0.00 sec)。如图2
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | wshop_store | +--------------------+ 5 rows in set (0.00 sec) mysql> use wshop_store Database changed mysql> show tables; Empty set (0.00 sec) mysql>
3、最终决定导入 SQL 文件至容器中。docker cp 本地文件路径 ID全称:容器路径。如图3
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b1209481ee68 startup_wshop-ingress "/docker-entrypoint.…" 18 hours ago Up 18 hours 0.0.0.0:80->80/tcp wshop-ingress dba654382ac1 startup_wshop-fpm "docker-php-entrypoi…" 18 hours ago Up 18 hours 9000/tcp wshop-fpm fd71ad5062cb mailhog/mailhog:latest "MailHog" 18 hours ago Up 18 hours 0.0.0.0:1025->1025/tcp, 0.0.0.0:8025->8025/tcp wshop-mailhog 60bc28cc2674 mysql:5.7 "docker-entrypoint.s…" 18 hours ago Up 18 hours 3306/tcp, 33060/tcp wshop-mysql 065679f42b04 wordpress:latest "docker-entrypoint.s…" 18 hours ago Up 18 hours 80/tcp wshop-wordpress 81ae20330d88 redis:alpine "docker-entrypoint.s…" 18 hours ago Up 18 hours 6379/tcp wshop-redis wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker inspect -f '{{.Id}}' wshop-mysql 60bc28cc267453f8f1df2655378023d241706177bb55b57cb46477a4d988f5d2 wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ pwd /mnt/e/wwwroot/xgrit wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ ls wshop wshop-wp wshop_store.sql wshop_wp.sql wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker cp /mnt/e/wwwroot/xgrit/wshop_store.sql 60bc28cc267453f8f1df2655378023d241706177bb55b57cb46477a4d988f5d2:/wshop_store.sql wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$
4、进入容器中,登录 MySQL 后,执行命令:source ./wshop_store.sql;。如图4
mysql> use wshop_store; Database changed mysql> show tables; Empty set (0.00 sec) mysql> source ./wshop_store.sql; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump: [Warning] Using a password on the command line interface can be insec' at line 1 Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec)
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/250666.html