Mac OS / 数据库 · 2019-08-25

‘caching_sha2_password’ cannot be loaded

django访问mysql数据库报错:

django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql-connector-c/6.1.11/lib/plugin/caching_sha2_password.so, 2): image not found")

mysql8.0用户密码加密方式为caching_sha2_password,django暂不支持,需要修改下mysql的加密方式:

登录mysql:

mysql -u root -p

查看当前加密方式:

use mysql;
select user,plugin from user where user='root';

修改加密方式:

alter user 'root'@'localhost' identified with mysql_native_password by 'password';

生效:

flush privileges;

作者:倪大头
链接:https://www.jianshu.com/p/939eb5157e83
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。