当前位置:首页 > php连接mysql时报错 SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

php连接mysql时报错 SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

点击次数:4845  更新日期:2019-07-21

php连接mysql时报错 SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

原因是 mysql8默认的身份验证方式是:caching_sha2_password

用phpinfo查询 loaded plugins,如果少了caching_sha2_password,就表明此版本的php不支持此验证方式

b_0_201807251440157037.jpg

解决方法为:

1、打开mysql命令行工具

2、执行命令 

      ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '111111';