docker build:错误:er\u不受支持\u auth\u模式:mysql客户端

bksxznpy  于 2021-06-24  发布在  Mysql
关注(0)|答案(2)|浏览(385)

当我尝试的时候 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'"

我只得到另一个错误。
我怎样才能解决这个问题?

fquxozlt

fquxozlt1#

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”,用于更改身份验证模式。

p3rjfoxz

p3rjfoxz2#

问题

从长远来看,您在入口点脚本中所做的实际上是在 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 命令,然后使用 -e flag(代表execute)。不管发生什么 -e 在mysql shell中执行(如查询等)。有关详细信息和示例,请参阅:
https://dev.mysql.com/doc/refman/8.0/en/command-line-options.html

相关问题