php连接mysql报错The server requested authentication method unknown to the client

php7.0连接mysql8.0报错:The server requested authentication method unknown to the client

是因为mysql80使用了新的密码验证插件:caching_sha2_password,而在php7.0并不支持这种方式。

解决办法:

​ 1.升级php

​ 2.修改mysql的配置文件,my.ini

​ 找到mysqlId下的default-authentication-plugin配置项修改其值为mysql_native_password

重启mysql即可。

posted @ 2020-06-05 20:10  杨欢喜e  阅读(5099)  评论(0编辑  收藏  举报