今天在用pycharm使用pymysql模块连接Mysql服务器的数据库,发现连接不到,错误代码是1130,pymysql.err.InternalError: (1130,'xxxxx' is not allowed to connect to this MariaDB server")

之后发现是权限问题。如下操作mysql库,即可解决。登录mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称'%'。。

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

mysql -u root -p

mysql>use mysql; #选择mysql库

mysql>update user set host = '%' where user ='root' and host='localhost'; #修改host值(以通配符%的内容增加主机/IP地址)

mysql>flush privileges; #刷新MySQL的系统权限相关表

退出mysql后再次登录需要使用mysql -h xxx.xxx.xxx.xxx  -uroot -p才能登录 (xxx.xxx.xxx.xxx为远程mysql服务器的ip地址)

---------------------
作者:MaybeOneDay
来源:CSDN
原文:https://blog.csdn.net/MaybeOneDay/article/details/79050153
版权声明:本文为博主原创文章,转载请附上博文链接!

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄