错误信息提示
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
原因
由于MySQL 8默认使用了新的密码验证插件:caching_sha2_password,而低版本的PHP版本中所带的mysqlnd无法支持这种验证。故报“请求客户端未知的身份验证方法”。
解决
方案一
可以通过phpinfo()函数了解当前安装的PHP是否支持caching_sha2_password
方案二
更改加密方式
alter user 'root'@'localhost' identified with mysql_native_password by '123456';
flush privileges;
卧槽。今天就遇到了。感谢博主