简体   繁体   中英

Access Remote MySQL database from VM Instance

I've been working with my Node App and deploy to VM Instance from Google Cloud. Now when I try to connect to RDS (Remote Database), it will flagged connect ETIMEOUT. One solution is to create a firewall rule which give access to database but still not working. May I ask if there's any alternative solution for this?

Not able to execute request.Error: connect ETIMEDOUT

To connect to the cloud database you have to make sure of a few things:

  • cloud database external ports are open
  • cloud database is set to receive external connections
  • you are using external ip, not internal ip
  • mysql conf for the db allows external connections
  • cloud database is online and ready to accept incoming connections
  • your node environment can accept connections on the said ports

To debug the issue, I suggest you use either a command line client or a dedicated mysql client instead of the node app. That way you can test the cloud system without having your node system as a factor.

The Google cloud instance database could be accesed by external connections if you follow the steps in this page:

https://cloud.google.com/sql/docs/mysql/connect-admin-ip#configure-instance-mysql

Basically, you need to manage your database instance ( https://console.cloud.google.com/sql/instances ), and allow an external connection from a known IP (your computer public IP address) as authorized network .

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