问题一:
SQLSTATE[HY000]: General error: 2006 MySQL server has gone away
问题二:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from user where id = 3)
Previous exceptions
- SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (2054)
- PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] (0)
问题原因:
(1)过去 MySQL 的密码认证插件是“mysql_native_password”。
(2)而当 mysql 到了 8.0 版以上时,密码认证插件使用的是“caching_sha2_password”。可是当前有很多数据库工具和链接包都不支持这个。
解决:
修改/etc/my.cnf文件:
[mysqld]
default_authentication_plugin=mysql_native_password
重启数据库:
service mysqld restart