【问题标题】:Unable to get remote access to MySQL / MariaDB on Centos7在 Centos7 上无法远程访问 MySQL / MariaDB
【发布时间】:2018-09-19 18:14:10
【问题描述】:

我试图远程访问我的 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

服务器在我的本地网络中,在不同的子网上。

内部防火墙设置为允许两个子网之间的连接,可以看到正在接受的流量。

关于它为什么不允许我远程访问的任何想法?

谢谢 克里斯

【问题讨论】:

  • 您是否尝试在禁用防火墙的情况下进行连接?只是为了检查它是否有效。如果在禁用防火墙的情况下无法正常工作,则问题与防火墙无关。
  • 嗨,是的,我尝试过不使用防火墙的直接访问。谢谢,克里斯。
  • 它是否可以在没有防火墙的情况下工作?!
  • 对不起,不管有没有它都不起作用。
  • 你得到什么错误?您可以从外部位置在 tcp 端口 3306 上远程登录您服务器的 IP 地址,以确保您可以实际连接到 mysql 吗?

标签: mysql mariadb centos7 iptables


【解决方案1】:

原来我将规则添加到 iptables 而不是 firewalld。将规则添加到 firewalld 后,我就可以远程访问服务器了。

【讨论】:

    猜你喜欢
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 2020-12-18
    • 2013-11-25
    • 2017-12-26
    • 2020-10-15
    • 2022-07-23
    相关资源
    最近更新 更多