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).
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