爱可生 DBA 团队成员,负责公司 DMP 产品的运维和客户 MySQL 问题的处理。擅长数据库故障处理。对数据库技术和 python 有着浓厚的兴趣。
本文来源:原创投稿
*爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源。
<hr/>前言
最近解决了一个比较基础的问题故障,由于排查过程挺有意思,于是就以此为素材写出了本篇文章。 故障现场
防火墙什么的均正常但是无法被远程访问到。简单的使用客户端登录了一下。
ERROR 2003 (HY000): Can&#39;t connect to MySQL server on &#39;127.0.0.1&#39; (111)
根据以往经验大脑中浮现了几个常见的排查此类故障手法
1.排查进程存在
[root@wx ~]# ps -ef|grep [m]ysql
mysql 25973 1 1 8月30 ? 02:43:20
/mysqldata/mysql/base/8.0.24/bin/mysqld --defaults-
file=/mysqldata/mysql/etc/3308/my.cnf --daemonize --pid-
file=/mysqldata/mysql/data/3308/mysqld.pid --user=mysql --
socket=/mysqldata/mysql/data/3308/mysqld.sock --port=33082.排查端口绑定情况,居然没有绑定端口
[root@wx ~]# lsof -i:3308
[root@wx ~]# ss -nltp|grep 33083.查看启动日志发现,监听端口等于0
2022-09-06T07:30:41.090649-00:00 0 [Note] [MY-010304] [Server] Skipping generation of SSL certificates as certificate files are present in data directory.
2022-09-06T07:30:41.094320-00:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-09-06T07:30:41.094806-00:00 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-09-06T07:30:41.095177-00:00 0 [Note] [MY-010308] [Server] Skipping generation of RSA key pair through --sha256_password_auto_generate_rsa_keys as key files are present in data directory.
2022-09-06T07:30:41.095500-00:00 0 [Note] [MY-010308] [Server] Skipping generation of RSA key pair through -- caching_sha2_password_auto_generate_rsa_keys as key files are present in data directory.
2022-09-06T07:30:41.124942-00:00 0 [System] [MY-010931] [Server] /mysqldata/mysql/base/8.0.24/bin/mysqld: ready for connections. Version: &#39;8.0.24&#39; socket: &#39;/mysqldata/mysql/data/3306/mysqld.sock&#39; port: 0 MySQL Community Server - GPL.
4.使用show variables命令查看确实是0
mysql> show variables like &#39;port&#39;;
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 0 |
+---------------+-------+