menu Chancel's blog
rss_feed
Chancel's blog
秋雨一何碧,山色倚晴空。

MariaDB远程访问错误

今天在内网机器上搭建一个测试MariaDB数据库,按照习惯配置远程访问

CREATE USER chancel@chancel IDENTIFIED BY 'chancel';
GRANT ALL PRIVILEGES ON chancel_api.* TO 'chancel'@'192.168.11.13' IDENTIFIED BY 'chancel' WITH GRANT OPTION;

然后在远程机器上访问到时候弹出了connect reset,这很明显说连接到端口就被拒绝了,看了下防火墙也是打开3306的默认端口,猜测下可能是MariaDB的问题

查查3306端口的情况

chancel@chancel-nas /etc/mysql/mariadb.conf.d » netstat -ntulp | grep 3306
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      127.0.0.1:3306            0.0.0.0:*               LISTEN

显然说db绑定了127.0.0.1的本地端口导致外网连接不了,找一下MariaDB到配置文件,编辑‘127.0.0.1’并改成'0.0.0.0'即可

chancel@chancel-nas ~» vim  /etc/mysql/mariadb.conf.d/50-server.cnf

...
bind-address		= 0.0.0.0 # 编辑‘127.0.0.1’并改成'0.0.0.0'即可
...
类型:Software
创建时间:2021 Jun 15
更新时间:2022 May 26

[[replyMessage== null?"发表评论":"发表评论 @ " + replyMessage.m_author]]

account_circle
email
web_asset
textsms

评论列表([[messageResponse.total]])

还没有可以显示的留言...
[[messageItem.m_author]] [[messageItem.m_author]]
[[messageItem.create_time]]
[[getEnviron(messageItem.m_environ)]]
[[subMessage.m_author]] [[subMessage.m_author]] @ [[subMessage.parent_message.m_author]] [[subMessage.parent_message.m_author]]
[[subMessage.create_time]]
[[getEnviron(messageItem.m_environ)]]