无法在centos7上远程访问mysql/mariadb

qyyhg6bp  于 2021-06-24  发布在  Mysql
关注(0)|答案(1)|浏览(520)

我试图远程访问我的mysql/mariadb服务器,但它一直拒绝我的访问。以下是我的设置:
iptables-l

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
INPUT_direct  all  --  anywhere             anywhere
INPUT_ZONES_SOURCE  all  --  anywhere             anywhere
INPUT_ZONES  all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere             ctstate INVALID
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

mysql数据库

MariaDB [(none)]> SELECT User, Host FROM mysql.user WHERE Host <> 'localhost';

+----------+------+
| User     | Host |
+----------+------+
| feed_user| %    |
+----------+------+

我的.cnf

[mysqld]
local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

!includedir /etc/my.cnf.d

netstat-plnt

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      30227/mysqld

服务器在我的本地网络中,在不同的子网中。
内部防火墙设置为允许两个子网之间的连接,可以看到正在接受的流量。
你知道为什么它不允许我远程访问吗?
谢谢克里斯

kiz8lqtg

kiz8lqtg1#

原来我是在给iptables添加规则,而不是防火墙。在将规则添加到firewalld之后,我可以远程访问服务器。

相关问题