首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >MySQL构建:错误: Docker :Docker client

MySQL构建:错误: Docker :Docker client
EN

Stack Overflow用户
提问于 2018-04-24 21:24:26
回答 2查看 5K关注 0票数 5

当我尝试docker-compose -f docker-compose-now.yml up时,我收到以下消息

代码语言:javascript
复制
error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

现在,我读到了这个解决方案:

代码语言:javascript
复制
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文件中呢

我的环境在这个文件中,当我尝试的时候:

代码语言:javascript
复制
entrypoints: sh "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root'"

我只得到另一个错误。

我该如何解决这个问题呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-04-25 14:43:52

问题

正确地说,您在入口点脚本中所做的事情实际上是在sh外壳中执行的。您要运行的命令应该在mysql外壳内执行。

解决方案

您的入口点应该使用以下命令来运行mysql命令:

代码语言:javascript
复制
mysql -u root -p [root-password] -e "update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';"

如果你想在mysql db上这样做,你可以这样做

代码语言:javascript
复制
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

票数 3
EN

Stack Overflow用户

发布于 2019-12-08 01:06:37

代码语言:javascript
复制
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模式。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50002848

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档