无法连接到“x.x.x.x”上的mysql服务器(110)

eqqqjvef  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(348)

你好,我有一个关于mysql的问题,我不能远程连接到它,我已经在这里找到了答案,但没有一个适合我!
这是我尝试连接mysql时的错误消息

  1. $> mysql -u user01 -h x.x.x.x -p

错误2003(hy000):无法连接到“x.x.x.x”上的mysql服务器(110)
电信网

  1. [root@machine2 ~]# telnet x.x.x.x 3306
  2. Trying x.x.x.x...
  3. telnet: connect to address x.x.x.x: Connection timed out

这就是 IPTABLES 文件

  1. # Generated by iptables-save v1.4.7 on Thu Jan 4 21:58:18 2018
  2. *filter
  3. :INPUT ACCEPT [56:6256]
  4. :FORWARD ACCEPT [0:0]
  5. :OUTPUT ACCEPT [35:3538]
  6. -A INPUT -p tcp -m tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
  7. -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
  8. -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
  9. -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
  10. -A INPUT -i lo -p tcp -m tcp --dport 3306 -j ACCEPT
  11. -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
  12. -A OUTPUT -p tcp -m tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT
  13. COMMIT
  14. # Completed on Thu Jan 4 21:58:18 2018

--我已经创建了一个用户

  1. CREATE USER 'user' IDENTIFIED BY 'pass';
  2. GRANT ALL PRIVILEGES ON *.* TO 'user';
  3. FLUSH PRIVILEGES;

这就是 my.cnf 文件

  1. # For advice on how to change settings please see
  2. # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
  3. [mysqld]
  4. port=3306
  5. skip-name-resolve
  6. skip-external-locking
  7. innodb_buffer_pool_size=3G
  8. #
  9. # Remove leading # and set to the amount of RAM for the most important data
  10. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
  11. # innodb_buffer_pool_size = 128M
  12. #
  13. # Remove leading # to turn on a very important data integrity option: logging
  14. # changes to the binary log between backups.
  15. # log_bin
  16. #
  17. # Remove leading # to set options mainly useful for reporting servers.
  18. # The server defaults are faster for transactions and fast SELECTs.
  19. # Adjust sizes as needed, experiment to find the optimal values.
  20. # join_buffer_size = 128M
  21. # sort_buffer_size = 2M
  22. # read_rnd_buffer_size = 2M
  23. datadir=/var/lib/mysql
  24. socket=/var/lib/mysql/mysql.sock
  25. # Disabling symbolic-links is recommended to prevent assorted security risks
  26. symbolic-links=0
  27. log-error=/var/log/mysqld.log
  28. pid-file=/var/run/mysqld/mysqld.pid

我的3306端口已经打开了

  1. [root@localhost ~]# netstat -petulan
  2. Active Internet connections (servers and established)
  3. Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
  4. tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 0 12889 2056/rpcbind
  5. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 13930 2441/sshd
  6. tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 0 13141 2133/cupsd
  7. tcp 0 0 0.0.0.0:32895 0.0.0.0:* LISTEN 29 12977 2078/rpc.statd
  8. tcp 0 0 x.x.x.x:22 x.x.x.x:49964 ESTABLISHED 0 7891927 4453/sshd
  9. tcp 0 64 x.x.x.x:22 x.x.x.x:50203 ESTABLISHED 0 7892871 4482/sshd
  10. tcp 0 0 :::3306 :::* LISTEN 27 7896831 6648/mysqld
  11. tcp 0 0 :::111 :::* LISTEN 0 12892 2056/rpcbind

有什么不对劲吗?谢谢!
我在用 CentOS 6.9

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题