首页 > 代码库 > Navicat远程连接不上mysql解决方案

Navicat远程连接不上mysql解决方案

[root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
[root@localhost ~]# /etc/rc.d/init.d/iptables save
bash: /etc/rc.d/init.d/iptables: 没有那个文件或目录
[root@localhost ~]# /etc/init.d/iptables restart
bash: /etc/init.d/iptables: 没有那个文件或目录
[root@localhost ~]# /etc/init.d/iptables status
bash: /etc/init.d/iptables: 没有那个文件或目录

 

CentOS7改了,以上命令有问题了,下面的可以。

# systemctl stop firewalld.service
# systemctl disable firewalld.servie

或者

# firewall-cmd --permanent --zone=public --add-port=3306/tcp


[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
success

紧接着,CentOS7上,

只允许用户root从ip为192.168.x.x的主机连接到mysql服务器,并使用password作为密码

GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.x.x‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;

FLUSH   PRIVILEGES;

 

操作如下:

登录到mysql

MariaDB [(none)]> use mysql;

MariaDB [mysql]>
MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘192.168.1.104‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> quit
Bye

 

客户端,连接成功。

Navicat远程连接不上mysql解决方案