'Cannot connect to mysql server in an Amazon EC2 instance

I have a problem in connecting to my MySQL server running on an EC2 Ubuntu instance.

In the /etc/mysql/mysql.conf.d/mysqld.cnf,

  • I've set the port=3306
  • I've set thebind-address=0.0.0.0.
  • Commented skip-external-locking

netstat -an | grep 3306 returns

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN

I allowed the connections using sudo ufw allow 3306

Still Iam getting the error as below. (I have added the db.apim.com to /etc/hosts )

ERROR 2003 (HY000): Can't connect to MySQL server on 'db.apim.com' (110)

Note : I followed everything in this blog



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source