pymysql.err.InternalError: (1130, "Host '192.168.16.144' is not allowed to connect to this MySQL ser

问题描述

mysql-client端连接mysql-server端报错,信息如下:

pymysql.err.InternalError: (1130, "Host '192.168.16.144' is not allowed to connect to this MySQL server")

注意:

1. mysql版本 14.14 Distrib 5.7.29 

2. 环境 ubuntu 18.04.4 LTS

原因:外部ip访问数据库并无权限,需要mysql-server端分配权限

解决方案:

mysql-server端

登录mysql: mysql -u root -p

允许外部所有ip访问(也可以指定某个ip)

GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password' with GRANT OPTION;

flush privileges;

exit;

Terminal窗口重启mysql server,命令如下

sudo /etc/init.d/mysql restart

 

你可能感兴趣的:(Ubuntu)