Home > OS >  Which port do I need to allow from AWS to my database?
Which port do I need to allow from AWS to my database?

Time:02-15

We are migrating our database from AWS to GCP. Our website is still hosted on an AWS EC2 instance for the moment.

We have allowed GCP to accept incoming connection from port 3306 with our EC2 instance's IP address.

I can ssh in to our EC2 instance and connect successfully to MySQL from the command line (port 3306), but if I try to connect programmatically on our EC2 instance we get a sql error: "Access denied for user 'my-user-name'@'162.8.X.X' (using password: YES)" (IP address is obviously replaced here). Do I need to allow a different port to accept the connection from our website? It's a PHP site if that makes any difference.

The connection is obviously being made, but my conclusion is that the port is incorrect.

CodePudding user response:

Access denied means that your application was able to successfully connect to your machine. So you can eliminate any network issues.

Check if your user is allowed to make a connection from that IP.

Do this command to see the users:

SELECT user,host FROM mysql.user;

'my-user-name'@'162.8.X.X' should be in there with either the ip, or with 'my-user-name'@'%'.

If the entry is correct, the only thing remaining to check is to see if the actual password is correct.

CodePudding user response:

Access denied for user is a error coming up from MySQL, so check the MySQL logs or password being passed as if there was a problem with your security group you might have got connection timed out error

  • Related