Navicat或者采集工具报错:…is not allowed to connect to this MySql server,MySQL不允许从远程访问的方法
解决方法:
1. 授权
例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; FLUSH PRIVILEGES;
如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器上db数据库,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON db TO 'myuser'@'192.168.1.6' IDENTIFIED BY 'mypassword' WITH GRANT OPTION; FLUSH PRIVILEGES;
2. 防火墙
CentOS7开启MySQL远程访问
CentOS7这个版本的防火墙默认使用的是firewall,与之前的版本使用iptables不一样。按如下方便配置防火墙:
1、关闭防火墙:
sudo systemctl stop firewalld.service
2、关闭开机启动:
sudo systemctl disable firewalld.service
3、安装iptables防火墙:
sudo yum install iptables-services
4、配置iptables防火墙,打开指定端口(CentOS6一样)
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT service iptables save service iptables restart
5、设置iptables防火墙开机启动:
sudo systemctl enable iptables