Home > Enterprise >  Cannot connect to mysql server in an Amazon EC2 instance
Cannot connect to mysql server in an Amazon EC2 instance

Time:02-11

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

CodePudding user response:

This is resolved by adding a suitable inbound traffic rule. By adding Type : TCP and Source: 0.0.0.0/0 as a new inbound traffic rule this issue resolved [1].

Thanks @GobindDeepSingh for pointing this out.

[1] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html

  • Related