Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

php - MySQL PHP不兼容SQLSTATE [HY000] [2054]服务器请求客户端未知的身份验证方法(MySQL PHP incompatibility SQLSTATE[HY000] [2054] The server requested authentication method umknown to the client)

I was trying to set up a mysql connection with php using PDO.

(我试图使用PDO与php建立mysql连接。)

Here are the version of the software I use :

(这是我使用的软件版本:)

  • windows 7 64

    (的Windows 7 64)

  • mysql 8.0.18

    (的MySQL 8.0.18)

  • php 7.3.11

    (的PHP 7.3.11)

And suddenly, the php server shows this error message :

(突然,PHP服务器显示此错误消息:)

Erreur : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

(错误:SQLSTATE [HY000] [2054]服务器请求客户端未知的身份验证方法)


It took me a long time to figure out what was happening.

(我花了很长时间才弄清楚发生了什么。)

This is the solution i've found : :

(这是我发现的解决方案::)

  • when you create the database user, use a mysql_native_password type for your password

    (创建数据库用户时,请使用mysql_native_password类型作为密码)

CREATE USER 'your_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';

mysql_native_password is the old authentification method to use instead of the new one who cause the error.

(mysql_native_password是一种旧的身份验证方法,而不是导致错误的新方法。)


I couldn't answer to the other post because of my 'reputation' on Stackoverflows, so I created my own post.

(由于在Stackoverflows上的“声誉”,我无法回答其他帖子,因此我创建了自己的帖子。)


If you're unable to load the PDO driver on windows, try this :

(如果您无法在Windows上加载PDO驱动程序,请尝试以下操作:)

  • in the php.file, change extension_dir from "ext" to the absolute path of the folder

    (在php.file中,将extension_dir从“ ext”更改为文件夹的绝对路径)

extension_dir = "C:\BAK\php_7.3.11\ext"

  ask by Mickael HUMPHREYS translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...