【问题标题】:Docker build: error: ER_NOT_SUPPORTED_AUTH_MODE: MySQL clientDocker 构建:错误:ER_NOT_SUPPORTED_AUTH_MODE:MySQL 客户端
【发布时间】:2018-04-24 13:24:25
【问题描述】:

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

我只得到另一个错误。

请问我该如何解决?

【问题讨论】:

    标签: mysql docker docker-compose dockerfile


    【解决方案1】:

    问题

    从长远来看,您在入口点脚本中所做的实际上是在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 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 标志执行sql 命令(它代表执行)。在 mysql shell 中执行 -e 之后的任何内容(如查询等)。有关详细信息和示例,请参阅:

    https://dev.mysql.com/doc/refman/8.0/en/command-line-options.html

    【讨论】:

    • 应该先sh,然后mysql -u root -p [root-password] mysql -e "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';"
    • 另外,请问-e是什么?
    • 更新了答案@JohnSam
    【解决方案2】:
    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 设置的“命令”,用于更改身份验证模式。

    【讨论】:

    • 提供没有解释的代码不是一个好的答案。请编辑您的答案,以便每个人都能理解所提供的解决方案是什么。
    • 我允许你帮我做
    猜你喜欢
    • 1970-01-01
    • 2022-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-25
    • 1970-01-01
    • 2015-05-25
    相关资源
    最近更新 更多