【问题标题】:Can't connect to MySQL server on '192.168.x.yyy'无法连接到“192.168.x.yyy”上的 MySQL 服务器
【发布时间】:2021-02-27 13:56:50
【问题描述】:

我正在尝试远程连接到数据库。

我把mysqld.cnf改成

  [mysqld]
  bind-address      = 192.168.x.yyy
  mysqlx-bind-address   = 192.168.x.yyy
  skip-networking

我用 iptables -S 检查了端口

   -A INPUT -p tcp -m tcp --dport 3306 -c 10 600 -j ACCEPT
   -A INPUT -p tcp -m tcp --dport 3306 -c 0 0 -j ACCEPT

我尝试运行 telnet 192.168.x.yyy 3306

   telnet: Unable to connect to remote host: Connection refused

当然,我打过电话

sudo service mysql restart

命令 mysql -u root -p 可以但是 mysql -h 192.168.x.yyy -u root -p 返回

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.x.yyy' (111)

mysql.user 包含的表:

mysql> select Host,User from user;

 +---------------+------------------+
 | Host          | User             |
 +---------------+------------------+
 | 192.168.x.yyy | root             |
 | ...
 | localhost     | root             |
 +---------------+------------------+

ifconfig 返回:

enp2s0f0: ...
   inet 192.168.x.yyy  netmask 255.255.255.0  broadcast 192.168.x.255

我正在运行 Ubuntu 20.04.1 LTS 和 mysqld 8.0.23

【问题讨论】:

    标签: mysql ubuntu


    【解决方案1】:

    在您引用的 mysqld.cnf 中,您包含了 skip-networking 规则,该规则禁用了对 MySQL 服务器的所有外部网络访问。

    如果需要远程访问,您应该删除此规则并重新启动您的 mysql 服务器进程。

    更多详情请参阅the documentation

    【讨论】:

    • 谢谢霍尔格。现在,它可以正常使用命令
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-08
    • 2020-12-03
    • 2021-02-17
    • 1970-01-01
    • 1970-01-01
    • 2010-09-27
    • 2015-05-10
    相关资源
    最近更新 更多