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即可。

原文地址:https://www.cnblogs.com/mrjkl/p/13052122.html