执行命令:docker exec -i object-mysql mysql -uroot -proot object_store < object_store.sql ,报错:mysql: [Warning] Using a password on the command line interface can be insecure.

1、执行命令:docker exec -i object-mysql mysql -uroot -proot object_store < object_store.sql ,报错:mysql: [Warning] Using a password on the command line interface can be insecure.。如图1

图1

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker exec -i object-mysql mysql -uroot -proot object_store < object_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 容器,查看数据库 object_store,显示所有表,响应:Empty set (0.00 sec)。如图2

图2

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| object_store        |
+--------------------+
5 rows in set (0.00 sec)

mysql> use object_store
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql>

3、最终决定导入 SQL 文件至容器中。docker cp 本地文件路径 ID全称:容器路径。如图3

图3

wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED        STATUS        PORTS                                            NAMES
b1209481ee68   startup_object-ingress    "/docker-entrypoint.…"   18 hours ago   Up 18 hours   0.0.0.0:80->80/tcp                               object-ingress
dba654382ac1   startup_object-fpm        "docker-php-entrypoi…"   18 hours ago   Up 18 hours   9000/tcp                                         object-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   object-mailhog
60bc28cc2674   mysql:5.7                "docker-entrypoint.s…"   18 hours ago   Up 18 hours   3306/tcp, 33060/tcp                              object-mysql
065679f42b04   wordpress:latest         "docker-entrypoint.s…"   18 hours ago   Up 18 hours   80/tcp                                           object-wordpress
81ae20330d88   redis:alpine             "docker-entrypoint.s…"   18 hours ago   Up 18 hours   6379/tcp                                         object-redis
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker inspect -f '{{.Id}}' object-mysql
60bc28cc267453f8f1df2655378023d241706177bb55b57cb46477a4d988f5d2
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ pwd
/mnt/e/wwwroot/xgrit
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ ls
object  object-wp  object_store.sql  object_wp.sql
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$ docker cp /mnt/e/wwwroot/xgrit/object_store.sql 60bc28cc267453f8f1df2655378023d241706177bb55b57cb46477a4d988f5d2:/object_store.sql
wangqiang@DESKTOP-QLPK8QM:/mnt/e/wwwroot/xgrit$

4、进入容器中,登录 MySQL 后,执行命令:source ./object_store.sql;。如图4

图4

mysql> use object_store;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> source ./object_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)
永夜