简体   繁体   中英

How to restore MySQL dump from file in docker container not using pass in terminal

I know about hub docs for mysql
$ docker exec -i some-mysql sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"' < all-databases.sql
But problem is that shell gives warning
[Warning] Using a password on the command line interface can be insecure.
and passing this warning to mysql occurre the error
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax;

I tried to set up.cnf file by copying into container

#/etc/mysql/my.cnf
[user]
user=root
password=root
host=localhost

Used this command mysql --login-path=user -uroot -proot
but mysql --print-defaults gives me only socket, not credentials
Also trying set up via mysql_config_editor , but mysql_config_editor: command not found
So, how can I restore dump?
MySQL version 8.0

Elide the offending line.

$ cat all-databases.sql |
  grep -v "Using a password on the command" |
  docker exec -i some-mysql sh ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM