调用Laravel concole命令的时候,日志里一直报以下错误:

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

MySQL8.0 更新了密码安全认证机制。

我们可以创建一个新的用户使用natvie password

CREATE USER 'ohdear_ci'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ohdear_secret';
GRANT ALL PRIVILEGES ON ohdear_ci.* TO 'ohdear_ci'@'localhost';

如果是已存在的用户

ALTER USER 'ohdear_ci'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ohdear_secret';