centos7下mysql配置远程连接

1、将 /etc/my.cnf 里的 bind-address = 127.0.0.1 注释掉

我们通过 netstat -apn|grep 3306 查看当前mysql网络状态信息

[root@www ~]# netstat -apn|grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      7893/mysqld

2、添加一个root用户,密码为123456,可访问所有权限,不限登陆主机

mysql -uroot -p
grant all privileges on *.* to 'root'@'%' identified by "123456" with grant option;

3、刷新权限

flush privileges;

4、修改vi /etc/sysconfig/iptables命令添加使防火墙开放3306端口

[root@www ~]# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT

5、重启防火墙

/etc/init.d/iptables restart

猜你喜欢

转载自blog.csdn.net/song634/article/details/80394965
今日推荐