centos 无法远程连接到MySQL数据库

cczfrluj  于 2022-11-07  发布在  Mysql
关注(0)|答案(1)|浏览(175)

我一直试图使用POPSQL连接到我的MySQL数据库,我一直得到错误代码ECONNREFUSED(错误连接被拒绝)M.Y.I.P:3306,我不知道为什么。设置如下:
我在Cent操作系统上运行Plesk,它使用MySQL DB(Maria),我通常通过Plesk界面使用PHPMyAdmin连接到MySQL DB。
现在我尝试使用此POPSQL连接到它,但我无法使用任何应用程序进行远程连接。
我的疑难解答:
1:重新启动服务器:多次,而且每次更换之后。
2:检查防火墙:它已启用,正在运行,端口3306已打开(我还尝试过通过SSH连接,我可以在终端中进行连接,但不能使用POPSQL或任何其他SQL连接软件)
3:检查Plesk配置:凭证正确,远程连接允许通过任何主机Plesk DB config
4:检查Maria配置,绑定地址是0.0.0.0而不是127.0.0.1

[mysqld]
bind-address = 0.0.0.0
local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

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

# 

# include all files from the config directory

# 

!includedir /etc/my.cnf.d

我的数据库故障排除知识到此为止,所以如果你有任何想法或建议,关于发生了什么以及如何修复它,请让我知道。再次,我是相当新的所有这一切,所以我相信这只是一个简单的错误,但一个额外的眼睛会非常有帮助。

aemubtdh

aemubtdh1#

我不擅长防火墙,这就说明了。
我正在编辑默认的防火墙区域“public”,而不是“plesk”,它控制着这台服务器的流量。
供日后参考:
1:检查哪些区域处于活动状态。

firewall-cmd --get-active-zones

2:编辑活动区域

firewall-cmd --zone=plesk**OR whatever your zone is called**--add-port=3306/tcp --permanent

2.5:确保它表示成功

firewall-cmd --zone=plesk --add-port=3306/tcp --permanent 
success

3:重新加载防火墙

firewall-cmd --reload

感谢贝恩德·布芬给我指明了正确的方向。
别忘了基础知识!

相关问题