修复python连接MySQL8.0.15数据库2059报错

1、点击开始->运行,输入cmd打开dos命令窗口;
修复python连接MySQL8.0.15数据库2059报错
2、输入cd C:\Program Files\MySQL\MySQL Server 8.0\bin命令切换到MySQL安装目录下的bin目录;
3、输入 mysql -u root -p 根据提示输入数据库密码;
修复python连接MySQL8.0.15数据库2059报错
4、执行命令:
use mysql;
select user,plugin from user where user=‘root’;
可以看到当前用户的加密方式为caching_sha2_password
修复python连接MySQL8.0.15数据库2059报错
5、执行命令:
alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘password’;
将用户的加密方式改为mysql_native_password
6、执行命令:
select user,plugin from user where user=‘root’;
可以看到当前用户的加密方式更新为mysql_native_password
修复python连接MySQL8.0.15数据库2059报错
7、执行命令:
flush privileges;
使权限配置项立即生效。