Mysql 设置远程连接访问
一、修改表
mysql -u root -p
use mysql;
update user set host = '%' where user = 'root';
select host, user from user;
二、授权
mysql -h localhost -u root GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
三、可能需要开放端口或者关闭防火墙
centos7版本对防火墙进行加强,不再使用原来的iptables,启用firewall
#通过systemctl status firewalld查看firewalld状态
#FirewallD is not running
systemctl unmask firewalld
systemctl start firewalld
#再次通过systemctl status firewalld查看firewalld状态,显示running即已开启了。
#再次执行执行firewall-cmd --permanent --zone=public --add-port=3306/tcp,提示success,表示设置成功,这样就可以继续后面的设置了。
firewall-cmd --reload
systemctl stop firewalld.service #关闭防火墙