今天用sqlalchemy连接mysql8.0数据库,一直报错,记录下解决方案
系统默认密码模式是caching_sha2_password
如需修改密码:必须使用mysql_native_password
select user,plugin from user;
然后用下面sql重置下密码,就可以连接了
alter user 'bittorrent'@'%' identified with mysql_native_password by 'bittorrent';
commit;
当然了,为了防止下次修改密码,导致加密模式变化,就是在my.cnf添加
#设置mysql 8.0 的加密方式为 mysql_native_password (默认为:caching_sha2_password)
default_authentication_plugin=mysql_native_password