简体   繁体   English

如何在不使用终端传递的情况下从 docker 容器中的文件恢复 MySQL 转储

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

I know about hub docs for mysql我知道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但问题是 shell 发出警告
[Warning] Using a password on the command line interface can be insecure.
and passing this warning to mysql occurre the error并将此警告传递给 mysql 发生错误
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我试图通过复制到容器中来设置 .cnf 文件

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

Used this command mysql --login-path=user -uroot -proot使用此命令mysql --login-path=user -uroot -proot
but mysql --print-defaults gives me only socket, not credentials但是mysql --print-defaults只给我套接字,而不是凭据
Also trying set up via mysql_config_editor , but mysql_config_editor: command not found还尝试通过mysql_config_editor设置,但mysql_config_editor: command not found
So, how can I restore dump?那么,如何恢复转储?
MySQL version 8.0 MySQL 版本 8.0

Elide the offending line.删除违规行。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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