mysql 故障解决

  • 客户端报 ERROR 2003 (HY000): Can't connect to MySQL server on 'host' (111)
  • 应用层连接池全部失败,服务不可用
  • telnet host 3306 连接拒绝
  • MySQL 服务未启动或已崩溃
  • 防火墙 / 安全组拦截了 3306 端口
  • bind-address 配置为 127.0.0.1,拒绝远程连接
  • 端口被其他进程占用
  1. 检查 MySQL 进程是否运行
    systemctl status mysqld ps -ef | grep mysqld
  2. 若服务已停止,尝试启动并查看错误日志
    systemctl start mysqld tail -100 /var/log/mysqld.log
  3. 检查端口监听
    ss -tlnp | grep 3306 netstat -tlnp | grep 3306
  4. 检查防火墙规则(CentOS / iptables)
    firewall-cmd --list-ports # 若需放行: firewall-cmd --permanent --add-port=3306/tcp && firewall-cmd --reload
  5. 检查 my.cnf 中 bind-address 配置
    # /etc/my.cnf 或 /etc/mysql/mysql.conf.d/mysqld.cnf # 改为 0.0.0.0 允许所有来源(生产注意配合白名单) bind-address = 0.0.0.0
上一篇 【Linux 网络】基于TCP的Socket编程:通过协议定制,实现网络计算器
下一篇 http和https的区别(简述)