当我尝试docker-compose -f docker-compose-now.yml up
时,我收到以下消息
error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
现在,我读到了这个解决方案:
use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';
来自:https://github.com/mysqljs/mysql/issues/1507
但是,如何将其放入entrypoints
中的docker-compose-now.yml
文件中呢
我的环境在这个文件中,当我尝试的时候:
entrypoints: sh "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root'"
我只得到另一个错误。
我该如何解决这个问题呢?
发布于 2018-04-25 14:43:52
问题
正确地说,您在入口点脚本中所做的事情实际上是在sh
外壳中执行的。您要运行的命令应该在mysql
外壳内执行。
解决方案
您的入口点应该使用以下命令来运行mysql
命令:
mysql -u root -p [root-password] -e "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';"
如果你想在mysql
db上这样做,你可以这样做
mysql -u root -p [root-password] mysql -e "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';"
解释
在这个命令中,首先使用mysql -u -p
命令进入mysql shell,然后使用-e
标志(它代表execute)执行sql命令。-e
之后发生的任何事情都是在mysql shell中执行的(比如查询等)。有关详细信息和示例,请参阅以下内容:
https://dev.mysql.com/doc/refman/8.0/en/command-line-options.html
发布于 2019-12-08 01:06:37
version: '3'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWOR=example
我在mysql镜像中找到了Docker hub的解决方案。它为docker-compose.yml设置了"command“,更改了auth模式。
https://stackoverflow.com/questions/50002848
复制相似问题