简体   繁体   中英

Issue connecting AWS EC2 instance to GCP database

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.XX' (using password: YES)" (IP address is obviously replaced here).

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.XX' 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM