简体   繁体   English

将 AWS EC2 实例连接到 GCP 数据库的问题

[英]Issue connecting AWS EC2 instance to GCP database

We are migrating our database from AWS to GCP.我们正在将我们的数据库从 AWS 迁移到 GCP。 Our website is still hosted on an AWS EC2 instance for the moment.我们的网站目前仍托管在 AWS EC2 实例上。

We have allowed GCP to accept incoming connection from port 3306 with our EC2 instance's IP address.我们已允许 GCP 接受来自端口 3306 与我们的 EC2 实例的 IP 地址的传入连接。

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).我可以将 ssh 连接到我们的 EC2 实例并从命令行(端口 3306)成功连接到 MySQL,但是如果我尝试以编程方式连接到我们的 EC2 实例,我们会收到 sql 错误:“拒绝访问用户 'my-user-name '@'162.8.XX' (using password: YES)”(IP地址显然在这里被替换了)。

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.检查是否允许您的用户从该 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'@'%'. 'my-user-name'@'162.8.XX' 应该与 ip 或 '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拒绝用户访问是来自 MySQL 的错误,因此请检查 MySQL 日志或传递的密码,就好像您的安全组有问题一样,您可能遇到连接超时错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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