0

I am running an Amazon Linux EC2 instance with MySQL v 5.5.54. I am also running a dev version of my application locally. Is there a way to connect to this remote MySQL database from my local machine?

I tried the standard:

mysql -h <my dns name> -P 3306 -u myuser -p

but my session hangs and nothing gets returned. I am also not seeing any connection attempts in EC2's MySQL logs.

dimitry_n
  • 2,939
  • 1
  • 30
  • 53

1 Answers1

2

Open port 3306 in the Security Group, with the inbound source set to your local IP address. Comment out the bind-address setting in my.cnf or change it to something like 0.0.0.0, and restart the MySQL service on the EC2 server. More info on bind-address here.

Alternatively, a more secure method would be to use SSH port forwarding.

Community
  • 1
  • 1
Mark B
  • 183,023
  • 24
  • 297
  • 295