你好,我有一个关于mysql的问题,我不能远程连接到它,我已经在这里找到了答案,但没有一个适合我!
这是我尝试连接mysql时的错误消息
$> mysql -u user01 -h x.x.x.x -p
错误2003(hy000):无法连接到“x.x.x.x”上的mysql服务器(110)
电信网
[root@machine2 ~]# telnet x.x.x.x 3306
Trying x.x.x.x...
telnet: connect to address x.x.x.x: Connection timed out
这就是 IPTABLES
文件
# Generated by iptables-save v1.4.7 on Thu Jan 4 21:58:18 2018
*filter
:INPUT ACCEPT [56:6256]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [35:3538]
-A INPUT -p tcp -m tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -i lo -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT
COMMIT
# Completed on Thu Jan 4 21:58:18 2018
--我已经创建了一个用户
CREATE USER 'user' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON *.* TO 'user';
FLUSH PRIVILEGES;
这就是 my.cnf
文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
port=3306
skip-name-resolve
skip-external-locking
innodb_buffer_pool_size=3G
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
我的3306端口已经打开了
[root@localhost ~]# netstat -petulan
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 0 12889 2056/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 13930 2441/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 0 13141 2133/cupsd
tcp 0 0 0.0.0.0:32895 0.0.0.0:* LISTEN 29 12977 2078/rpc.statd
tcp 0 0 x.x.x.x:22 x.x.x.x:49964 ESTABLISHED 0 7891927 4453/sshd
tcp 0 64 x.x.x.x:22 x.x.x.x:50203 ESTABLISHED 0 7892871 4482/sshd
tcp 0 0 :::3306 :::* LISTEN 27 7896831 6648/mysqld
tcp 0 0 :::111 :::* LISTEN 0 12892 2056/rpcbind
有什么不对劲吗?谢谢!
我在用 CentOS 6.9
暂无答案!
目前还没有任何答案,快来回答吧!