错误信息: SQL Error (1130): Host ‘192.168.1.88’ is not allowed to connect to this MySQL server
说明所连接的用户帐号没有远程连接的权限,只能在本机(localhost)登录
需更改 mysql
数据库里的 user表里的 host
项
把localhost
改为%
登录mysql
服务器,执行以下命令
mysql>use mysql
mysql>select user,host,plugin from user;
mysql>update user set host='%' where user='root' and host='127.0.0.1';
mysql>flush privileges;
1.云服务器设置远程访问需要防火墙开放 3306 端口,否则连接不上
2.服务器本身防火墙记得放行 3306 端口(firewalld、iptables)
plugin 可以考虑使用 mysql_native_password
(MySQL8默认即可)避免客户端兼容性问题。
附:防火墙的禁用与查看
1、运行、停止 iptables
查看状态:service iptables status
停止:service iptables stop
启动:service iptables start
如:防火墙放行 3306
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
service iptables save
service iptables restart
2、运行、停止、禁用 firewalld
查看状态:systemctl status firewalld 或者 firewall-cmd –state
停止:systemctl stop firewalld
启动:systemctl start firewalld
禁用:systemctl disable firewalld
systemctl mask firewalld
systemctl unmask firewalld
1 thought on “mysql8允许外部远程连接设置”