mysql8允许外部远程连接设置

错误信息: 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

2、运行、停止、禁用 firewalld
查看状态:systemctl status firewalld 或者 firewall-cmd --state
停止:systemctl stop firewalld
启动:systemctl start  firewalld

禁用:systemctl disable firewalld
systemctl mask firewalld
systemctl unmask firewalld
Author: thinkwei

1 thought on “mysql8允许外部远程连接设置

回复 Mysql8的用户授权 – JeeInn的技术分享 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注