0

I'm trying to allow remote connections to one of my mysql databases, but after I set everything up, I keep getting a time out error. Can you tell me if I perhaps missed a step?

I'm running Ubuntu 12.04 with MySQL 5.5.38-0

Here's my /etc/mysql/my.cnf file

[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
# skip-external-locking
bind-address    = 0.0.0.0

Once I updated the my.cnf file, I restarted MySQL and then ran the following to open TCP port 3306

sudo /sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT

Then saved the new rules using:

sudo /sbin/iptables-save

I can see it when I run sudo iptables -L

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
DROP       udp  --  anywhere             anywhere             udp spt:bootps
LOG        all  --  anywhere             anywhere             LOG level warning prefix "INPUT__"
DROP       all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql

I then created a test database:

> create database kentest;

Granted it all privileges from any host:

> GRANT ALL ON kentest.* TO kentest@'%' IDENTIFIED BY 'mypassword';

And flushed the privileges:

> flush privileges

But when I try and connect from another box:

$ mysql -u kentest -h x.x.x.x -p

I get the timeout message:

ERROR 2003 (HY000): Can't connect to MySQL server on 'x.x.x.x' (60)

I did notice that I don't see the port being used when I run

$ lsof -i -P | grep :3306

Any ideas what I could be doing wrong or missing?

Thanks!

Ken
  • 626
  • 1
  • 8
  • 22

1 Answers1

0

I was able to figure out the issue. We are using CSF for our firewall and needed to add the IP to:

sudo vi /etc/csf/csf.allow

Then restart CSF:

$ csf --restart
Ken
  • 626
  • 1
  • 8
  • 22