美文网首页
解决报错:_mysql_exceptions.Operation

解决报错:_mysql_exceptions.Operation

作者: Calyn0709 | 来源:发表于2018-06-26 13:57 被阅读0次

本地环境:

python2.7.15

MySQL8.0

MySQL-python 1.2.5

执行:

>>> import MySQLdb

>>> conn = MySQLdb.connect(host="localhost",user="root",passwd="123456",db="sunck")

遇到报错:

_mysql_exceptions.OperationalError: (1251, 'Client does not support authentication protocol requested by server; consider upgrading MySQL client')

解决办法:

命令行输入:

mysql -u root -p

输入密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

mysql> FLUSH PRIVILEGES;

更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。

相关文章

网友评论

      本文标题:解决报错:_mysql_exceptions.Operation

      本文链接:https://www.haomeiwen.com/subject/pnapyftx.html