切换mysql8.0后报错 SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
原因:PHP的一个bug
- 参考:
mysql 升级了caching_sha2_password php
无法识别
[2019-12-27 15:45 UTC] nikic@php.net
Closing this as caching_sha2_password is in principle supported on 7.4 -- though there are a couple of different bugs that may affect it, tracked at bug #78981 and bug #79011.
解决方案:
方案一、修改配置文件database.php
方案二、如果你使用的是docker:
方案三、修改mysql配置
- 命令行输入
mysql
- 输入下面命令
ALTER USER '你的用户名'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
- 不想设置密码可以留空.
-
.env
在项目中使用新用户