2

I understand this question has been asked but they all say the same thing which I have tried and failed.

Basically using this site: http://www.yougetsignal.com/tools/open-ports/ I can see my 3306 port is closed and trying to get a client to connect remotely is not working. I have changed the /etc/mysql/my.cnf file to both commented out bind-address and also change it to 0.0.0.0 but neither worked.

I have tried iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT but it doesn't seem to do anything.

My iptables all show ACCEPT

-P INPUT ACCEPT -P FORWARD ACCEPT -P OUTPUT ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306

Does anyone have any other idea as to why this port is still blocked?

Thanks

Additional information [EDIT]

When I try to use: mysqli_connect('XX.XX.XX.XXX', "DBUSer", "DBPassword", "DBName", 3306); it gives my the error PHP Warning: mysqli_connect(): (HY000/2003): Can't connect to MySQL server on 'XX.XX.XX.XX (60)

I also typed into my server: ufw status; Status: inactive

MomasVII
  • 4,641
  • 5
  • 35
  • 52
  • Is there a hardware firewall? – Brian Gottier Aug 23 '17 at 00:51
  • Is the server on the internet, or is it on a private network? – lurker Aug 23 '17 at 00:52
  • Is there a software firewall? Fiddling around with the MySQL configuration is starting at the wrong end. The first question is, what error do your clients get? 'Connection refused' or 'connect timeout'? – user207421 Aug 23 '17 at 00:53
  • It is a custom built application that just says 'unable to connect to mysql database'. But that could mean anything. I get a php error when using mysqli_connect: PHP Warning: mysqli_connect(): (HY000/2003): Can't connect to MySQL server on 'XX.XX.XX.XX (60) if that helps. command `mysqli_connect('XX.XX.XX.XXX', "DBUSer", "DBPassword", "DBName", 3306);` – MomasVII Aug 23 '17 at 01:22
  • It is a server on the internet for a website application we have developed. – MomasVII Aug 23 '17 at 01:23
  • I also typed: `ufw status; Status: inactive` so does that mean my firewall is inactive? – MomasVII Aug 23 '17 at 01:39
  • 1
    Did you restart mysql server service after change /etc/mysql/my.cnf? This seems obvious but...the server is running/ – Joao Vitorino Aug 23 '17 at 01:47
  • Yeah I restarted it. Still nothing. – MomasVII Aug 23 '17 at 02:13
  • Try `telnet XX.XX.XX.XX 3306` and tell us the result. – user207421 Aug 23 '17 at 02:32
  • NB `(60)` is an `errno` value in your local systenm. What does it mean? – user207421 Aug 23 '17 at 02:41

2 Answers2

0

Thanks everyone.

Turns out the team that set up the server needed to make a change on their end. They didn't say specifically but it opened the port up. (I imagine it was a firewall setting)

I also had to grant privileges to all host with:

GRANT ALL ON *.* to DBUsername@'%' IDENTIFIED BY 'DBPassword';

I had always seen the DBUsername@'xx.xx.xx.xxx' and didn't know I had to '%' it to work for all IPs.

Thanks

MomasVII
  • 4,641
  • 5
  • 35
  • 52
0

I had the same issue, and i try add a new rule in outbound rule (in firewall advanced setting) for port 3306. Or you can configure the Mysql setting, while you setting, tick the box to allow remote from another machine.

hangle
  • 1