0

I hope you are well.

I wan't to connect Google Datastream with MySQL database hosted into Cloud SQL by using private connection.

I have conected by the public internet using Public IP but I need to connect through VPC peering for security, documentation indicates that the following should be done: https://cloud.google.com/datastream/docs/private-connectivity

I have been tring to connect across Cloud SQL Auth Proxy follow this documentation and I have already connected the proxy to Cloud SQL: https://cloud.google.com/sql/docs/mysql/connect-admin-proxy#tcp-sockets

In every occasion I see the same error, no matter what ip configure it always changes to another ip.

For example, the follow image show the perfil configuration with Cloud SQL Auth Proxy internal IP 10.128.0.2 set up.

Perfil configuration

And, when I try to test, I've seen that the MySQL IP change for 192.168.5.236 Connection mistake

Philipp Sh
  • 967
  • 5
  • 11

2 Answers2

2

In general, this is a MySQL client-side error code. The possible causes for this error are:

  • MySQL Server not running, or

  • Firewall configuration on the Windows server blocking access on port 3306

=> To troubleshoot the given error message, please follow the below mentioned steps:

  1. Verify MySQL server is running and use the ping command to check the client-server connectivity. For Example: ping server_ip_address

  2. To connect to a Cloud SQL instance using private IP, the Cloud SQL Auth proxy must be on a resource with access to the same VPC network as the instance.[1]

  3. When you start the Cloud SQL Auth proxy, to ensure it is using the private IP, please make sure to pass the flag:

 -ip_address_types=PRIVATE

  1. Also,verify the firewall configuration and make sure the port 3306 is not blocked.

  2. You can also view the mysql config file[2] and check if there is a bind-address relevant to it. If there is a bind-address, comment it out using the # character.

[1] https://cloud.google.com/sql/docs/mysql/connect-admin-proxy#private-ip

[2] How do I find the MySQL my.cnf location

  • Thanks Dilpreet Kaur, the problem was the firewall rule. I used de default VPC witch allow only tcp:3306 connection from the ip ranch in compute engine not from the new IP range in Datastream. – Julio Ayala Nov 11 '21 at 15:18
1

In my case I have the Cloud SLQL Proxy mounted in compute engine and Mysql in Cloud SQL.

The solution was the following:

I needed to create a ingress firewall rule allow the ip range from the Datastream Private Connection (I needed to connect Datastream across a private connection for governance) to Cloud SQL Auth Proxy IP Range in tcp:3306.

You can test your connection throght Connectivity Tests