2022-07-17 15:28:51[小技巧]MySQL: Connection Refused排查方案
您现在的位置是: 首页 > 数据 > [小技巧]MySQL: Connection Refused排查方案
详细记录了是如何一步一步排查mysql拒绝连接的问题。
正文:
1. 从远程定位问题
ping ip : 检测机器是否可以连的通
telnet ip port : 检测端口是否有开放
2. 从机器内部定位
1. 查看mysql服务是否开启
ps -ef|grep mysqld
2. 查看tcp端口是否开启
netstat -tnpl
3. 查看mysql是否指定了bind-address
vim /etc/mysql/my.cnf
4. 查看mysql的账号是否允许外部连接(需要重启mysql:/etc/init.d/mysqld restart)
mysql -u root -p
use mysql
select user,host from user;
update user set host=‘%’ where user=‘root’;
或
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
5. 查看防火墙是否开启3306端口
iptables -S
/sbin/iptables -I INPUT -p tcp --dport 8011 -j ACCEPT #开启8011端口
/etc/init.d/iptables restart
关键字词: [小技巧]MySQL: Connection Refused排查方案
上一篇: 问题解决:Failed to download metadata for repo ‘appstream‘: Cannot prepare internal mirrorlist:...
下一篇: PHP处理Excel时间