mysql 开启远程访问 常见问题

端口检测:
netstat -ntpl |grep 3306
如果只绑定了本机 参看1.3 否则参考2

  1. 打开mysql配置文件 vi /etc/my.cnf
    不同的版本位置可能不同 如果有bind-address = 127.0.0.1 注释或者删掉
  2. 进入mysql 执行:

    grant all privileges on *.* to 'root'@'%' identified by 'xxxxxx'; //任何位置可以连接
    flush privileges;​ //立即生效
  3. 开启防火墙3306端口

     vi /etc/sysconfig/iptables
     //添加如下内容 
     -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
     /etc/init.d/iptables restart(重启防火墙使配置生效)
     // 或者直接关闭防火墙;

猜你喜欢

转载自blog.csdn.net/lkjasdgfh/article/details/79738789