一则mysql 登录问题处理
今天在升级数据库之后,不小心将my.cnf中的端口号从3306修改为3606,没有发现,导致Prometheus监控客户端无法登录。
报错如下:
[root@capdb_uat1 ~]# mysql -uexporter -p -h127.0.0.1
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
一阵排查之后,才发现是端口不对。MySQL客户端登录,如果不指定端口号,默认使用 3306的端口号。
因为将端口修改为 3606(非默认),所以在通过IP 登录,必须指定端口号。如下:
[root@capdb_uat1 ~]# mysql -uexporter -p -h127.0.0.1 -P3606
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.36-log MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
经验总结:
1.启动MySQL之后,首先检查错误日志,看没有异常
2.检查MySQL占用的端口是否已正常启用,可通过比如: lsof -i:3306 检查端口是否处理侦听状态。
3.尝试通过本地及IP方式登录数据库,检查数据库状态

浙公网安备 33010602011771号