当我尝试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
但是如何将其放入docker-compose-now.yml
中的entrypoints
文件中?
我的环境在此文件中,并且当我尝试时:
entrypoints: sh "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root'"
我只收到另一个错误。
我该如何解决?
为了清楚起见,您在入口点脚本中所做的实际上是在sh
shell中执行的。您要运行的命令应在mysql
shell中执行。
您的入口点应该具有以下命令来运行mysql
命令:
mysql -u root -p [root-password] -e "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';"
如果您想在mysql
数据库上执行此操作,则可以执行此操作
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
标志执行sql命令(它代表execute)。在mysql shell中执行-e
之后发生的一切(例如查询等)。有关详细信息和示例,请参考:
https://dev.mysql.com/doc/refman/8.0/en/command-line-options.html
version: '3.1'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
adminer:
image: adminer
restart: always
ports:
- 8080:8080