当前位置:Gxlcms > 数据库问题 > [HY000] [2054] php连接mysql时错误

[HY000] [2054] php连接mysql时错误

时间:2021-07-01 10:21:17 帮助过:11人阅读

会出现这样的原因,主要都是因为mysql8.0版本的缘故,8.0版本默认编码为utf8mb4
解决方法:
MySQL配置文件my.ini中[mysqld]下加这两行

character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci

然后又出现了另一个问题:The server requested authentication method unknown to the client
也是由于mysql版本缘故,8.0版本mysql账号密码解锁机制不一致
在数据库操作界面输入命令
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘账户密码‘;即可

或者在MYSQL配置文件my.iniz中[mysqld]下加入
default_authentication_plugin=mysql_native_password

[HY000] [2054] php连接mysql时错误

标签:sql   错误   serve   col   不一致   auth   版本   char   nat   

人气教程排行