I'm trying to allow remote traffic to my mysql server. I changed my bind address in my mysqld.cnf to, and ran sudo ufw allow 3306/tcp but I don't think my port 3306 is allowing traffic.

Amazon EC2 security rule allowing 3306 access

I'm trying to access the mysql server to store dev, staging and production.

  • running it on amazon ec2 instance should be good. ill add a picture.
    – Jay
    Jun 19 '18 at 3:28
  • Did you restart the mysql service after changing the configuration? How did you check whether it is listening? Jun 19 '18 at 3:44
  • i did. and I ran netstat -l
    – Jay
    Jun 19 '18 at 4:01
  • Check if you not have --skip-networking option when mysql daemon starts. How to check: ps -ef | grep mysql and check used options. What you got, when run ss -tnpl | grep 3306?
    – mariaczi
    Jun 19 '18 at 6:39
  • ps -ef | grep mysql returns 7290 7273 0 14:02 pts/0 00:00:00 grep --color=auto mysql ss -tnpl | grep 3306 doesn't return anything
    – Jay
    Jun 19 '18 at 14:04

Do this test from different sites in your infrastructure.

Install nmap like so,

sudo apt-get install nmap

and then try to scan the database server like so:

From localhost/same machine do

sudo nmap -sS

From the same network/other machine close by do (e.G.)

sudo nmap -sS 192.168.X.X

From the Internet do (e.G.)

 sudo nmap -sS 80.34.X.X 

If the first and second test go well, you have a problem with your router. This problem is then not Ubuntu-related anymore, but a problem with the router you use to connect to the internet.

If the first test fails, your port is completly closed and you have to work on your mysql conf again.

If the first succeeds and the second one fails, recheck that mysql really listens to 3306. Do a

 sudo netstat -tlpn

Check that is the source ip for port 3306/tcp. If that is the case you will have to recheck the settings with ufw. Disable the ufw for testing, to see if it makes a difference.

  • Its an amazon ec2 instance. I don't control the router, but I can set up security rules. nor do I have other devices on the same network.
    – Jay
    Jun 19 '18 at 16:12
  • Oh, so you have no neighbouring machines? thats too bad. What happens, if you use nmap from your home (from the internet). Is there no port open? It should have ssh open, so you can connect. Does it list any other ports? Did you check netstat to see if mysql is set to
    – s1mmel
    Jun 20 '18 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.