Loading

数据库远程连接报错ERROR 2003 (HY000): Can't connect to MySQL server on '10.102.169.77' (111)

1.报错如下:
ERROR 2003 (HY000): Can't connect to MySQL server on '10.102.169.77' (111)
ERROR 2003 (HY000): Can't connect to MySQL server on '10.0.0.163' (111 "Connection refused")

2.telnet也无法访问。检查3306端口也一直在打开。
检查后发现数据库监听在本地127.0.0.1所以无法访问。修改配置文件后让监听所有主机。

# vim /etc/mysql/mariadb.conf.d/50-server.cnf 
bind-address            = 127.0.0.1    # 修改为0.0.0.0

3.重启数据库

# systemctl restart mariadb

4.测试访问。

# mysql -h 10.102.169.xx  -P3306 -uhaitang -pxxxx
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.1.48-MariaDB-0ubuntu0.18.03.1 Ubuntu 18.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
posted @ 2022-07-21 20:18  梨花海棠  阅读(959)  评论(0编辑  收藏  举报