LNMP mysql默认不能远程连接
LNMP1.6版本 安装完成后,默认的MySQL不能通过navicat等工具远程连接管理
需要做两个操作:关闭3306的防火墙,设置mysql的root(或其他用户)的允许主机(host)为所有
1. 先修改防火墙
iptables -L -n --line-numbers
3306端口target 为DROP
2. 删除这两个端口
iptables -D INPUT 5
iptables -D INPUT 14
3. 然后重新添加3306 target为ACCEPT
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
4. 保存并重启iptables
service iptables save
service iptables restart
5. 接着修改mysql的root访问host
mysql -u root -p
use mysql;
update user set host = '%' where user = 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;
exit;
service mysql restart;