Docker中的MySQL返回“客户端不知道的服务器请求的身份验证方法". [英] MySQL in Docker returns "The server requested authentication method unknown to the client"
问题描述
我将Symfony 4项目使用Docker Web堆栈. MySQL配置是:
I use a Docker web stack for Symfony 4 project. MySQL configuration is :
mysql:
image: mysql
container_name: sf4_mysql
volumes:
- .docker/data/db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ***
MYSQL_USER: ***
MYSQL_PASSWORD: ***
从Docker Hub提取的映像是MySQL 8,当我尝试使用doctrine:database:create
创建数据库时,收到此消息:
The pulled image from Docker Hub is MySQL 8 and when I tried to create database with doctrine:database:create
I received this message :
2018-09-17T11:53:51 + 00:00 [错误]运行命令"doctrine:database:create"时引发错误.消息:驱动程序中发生异常:SQLSTATE [HY000] [2054]服务器请求认证我 客户端未知"
2018-09-17T11:53:51+00:00 [error] Error thrown while running command "doctrine:database:create". Message: "An exception occurred in driver: SQLSTATE[HY000] [2054] The server requested authentication me thod unknown to the client"
在AbstractMySQLDriver.php第126行中:
In AbstractMySQLDriver.php line 126:
驱动程序中发生异常:SQLSTATE [HY000] [2054]服务器请求了客户端未知的身份验证方法
An exception occurred in driver: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
在PDOConnection.php第50行中:
In PDOConnection.php line 50:
SQLSTATE [HY000] [2054]服务器请求了客户端未知的身份验证方法
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
在PDOConnection.php第46行中:
In PDOConnection.php line 46:
SQLSTATE [HY000] [2054]服务器请求了客户端未知的身份验证方法
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
在PDOConnection.php第46行中:
In PDOConnection.php line 46:
PDO :: __ construct():服务器请求了客户端[caching_sha2_password]未知的身份验证方法
PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]
推荐答案
只需按照以下说明更新docker-compose文件并重建映像即可.
just update your docker-compose file as given below and rebuild the image.
mysql:
image: mysql
command: --default-authentication-plugin=mysql_native_password
container_name: sf4_mysql
volumes:
- .docker/data/db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ***
MYSQL_USER: ***
MYSQL_PASSWORD: ***
这篇关于Docker中的MySQL返回“客户端不知道的服务器请求的身份验证方法".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!