Search code examples
mysqlamazon-web-servicesplesk

AWS Plesk instance, how to open port 3306


I'm attempting to connect to a MYSQL database remotely. When trouble shooting I notice that the port is closed:

nmap -p 3306 34.34.34.34 (substituting for my server ip)

returns

PORT     STATE  SERVICE
3306/tcp closed mysql

In mysql config found at /etc/mysql/my.cnf I have

# Port or socket location where to connect
port = 3306
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
[mysqld]
sql_mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#bind-address = 0.0.0.0
local-infile=0

From with in server: sudo ufw status

shows that 3306 is open:

3306                       ALLOW       Anywhere                  
3306 (v6)                  ALLOW       Anywhere (v6)     

In my EC2 security group I have 3306 open to ipv4 0.0.0.0/0

In plesk I have: Allow remote connections from any host selected

Any idea why I can't connect to the mysql database?


Solution

  • I solved this by changing the binding ip address in one of the include dir files:

    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mariadb.conf.d/
    

    These directories included multiple files and in one of them there was

    bind-address = 127.0.0.1
    

    I changed it to: #bind-address = 127.0.0.1