debian 11 + mariadb 远程连接

debian 11 + mariadb 远程连接

在全新安装的 Debian 11 上,我无法让 mariadb 接受远程连接。

我已将绑定地址更改为bind-address: 0.0.0.0。从同一台服务器,我可以顺利地远程登录到端口 3306。从远程服务器,我收到连接被拒绝错误或错误 2002 (115)。

目前没有运行防火墙。我可以顺利地通过 telnet 进入其他服务端口,但无法通过 mysql 进入。我遗漏了什么?

带有 MariaDB 的服务器

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN

来自服务器的连接

telnet 192.168.0.143 3306
Trying 192.168.0.143...
Connected to 192.168.0.143.
Escape character is '^]'.
c
5.5.5-10.5.15-MariaDB-0+deb11u1#l#dQKa&9▒▒-+kZ`VmBBbFxMmysql_native_password

来自客户端的连接

telnet 192.168.0.143 3306
Trying 192.168.0.143...
telnet: Unable to connect to remote host: Connection refused
mysql -u user -p -h 192.168.0.143
Enter password:
ERROR 2002 (HY000): Can't connect to MySQL server on '192.168.0.143' (115)

更新

我真的不知道发生了什么。从这个盒子里,我可以使用 127.0.0.1、192.168.0.143 或外部 IP 访问 mysql,没有任何问题。

当尝试从任何其他盒子连接时,它就像被防火墙阻止了一样。

  • 我通常使用 iptables,但我已经清除了所有规则,刷新了所有表,并且所有策略都设置为接受。
  • 我的云主机上没有运行防火墙——已与他们的支持团队核实。
  • 其他服务在外部连接正常,这实际上指向了 mariadb 特有的问题。

MariaDB 当前绑定到应用程序 ipv4 和 ipv6 接口。我尝试过仅绑定到 ipv4,将默认端口更改为 3306 以外的其他端口。

Dec 29 15:57:14 myserver systemd[1]: Starting MariaDB 10.10.2 database server...
Dec 29 15:57:14 myserver mariadbd[141636]: 2022-12-29 15:57:14 0 [Note] /usr/sbin/mariadbd (server 10.10.2-MariaDB-1:10.10.2+maria~deb11) starting as process 141636 ...
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Number of transaction pools: 1
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Using liburing
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Completed initialization of buffer pool
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: 128 rollback segments are active.
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: log sequence number 45507; transaction id 20
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] Plugin 'FEEDBACK' is disabled.
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] InnoDB: Buffer pool(s) load completed at 221229 15:57:15
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] Server socket created on IP: '0.0.0.0'.
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] Server socket created on IP: '::'.
Dec 29 15:57:15 myserver mariadbd[141636]: 2022-12-29 15:57:15 0 [Note] /usr/sbin/mariadbd: ready for connections.
Dec 29 15:57:15 myserver mariadbd[141636]: Version: '10.10.2-MariaDB-1:10.10.2+maria~deb11'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
Dec 29 15:57:15 myserver systemd[1]: Started MariaDB 10.10.2 database server.

相关内容