Tuesday, February 17, 2015

MySQL refuses to accept remote connections

I've just installed a fresh ubuntu server with mysql (percona 5.5), but it refuses to accept connections from remote hosts



Here is what happens if I try to connect to this server remotely:



mysql -h10.0.0.2 -uroot -pmypassowrd

ERROR 2003 (HY000): Can't connect to MySQL server on '10.0.0.2' (111)

telnet 10.0.0.2 3306
Trying 10.0.0.2...
telnet: Unable to connect to remote host: Connection refused


When I checked if mysql listens to remote connections I saw this:



sudo netstat -ntlup | grep mysql

tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 127018/mysqld


As you can see it says 127.0.0.1:3306 which means "I accept only local connections".



I checked my skip_networking and bind-address variables - everything is turned off:



mysql> show variables like '%skip_networking%';
+-----------------+-------+
| Variable_name | Value |

+-----------------+-------+
| skip_networking | OFF |
+-----------------+-------+
1 row in set (0.00 sec)

mysql> show variables like '%bind%';
Empty set (0.00 sec)


I have another server with absolutely the same config and it works great:




sudo netstat -ntlup | grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2431/mysqld


What can be the reason for this? How do I make mysql respond to remote connections?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...