egg-mysql连接mysql8问题
JyLie 2023-10-13 mysqlegg-mysql
# 问题
解决egg-mysql连接不上MySql服务器报错:Client does not support authentication protocol requested by server; consider upgrading MySQL client
# 分析
查阅文档,发现是由于navicat版本的问题造成连接失败。
mysql8 之前的版本中加密规则是mysql_native_password
,
而在mysql8之后,加密规则是caching_sha2_password
# 解决
将加密规则 caching_sha2_password
改为 mysql_native_password
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '[mysql_password]' PASSWORD EXPIRE NEVER;
# 关键在于修改规则
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[mysql_password]';
、、 刷新权限,使修改生效。
mysql> FLUSH PRIVILEGES;
# 查看表中相关信息,确认修改是否真正生效
mysql> use mysql; //先使用命令 use mysql
Database changed
mysql> select user,host,plugin from user where user='root'; // 在输入该命令
+------+-----------+-----------------------+
| user | host | plugin |
+------+-----------+-----------------------+
| root | localhost | mysql_native_password |
+------+-----------+-----------------------+
1 row in set (0.00 sec)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15