Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

GCP Datastream Private connection - can't connect to MySQL Server

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 trying 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, In the follow image I show you the perfil configuration with Cloud SQL Auth Proxy internal IP 10.128.0.2 set up.

CBhad.png

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

tPKUA.png

0 1 1,020
1 REPLY 1

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

```

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

5) 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] https://stackoverflow.com/questions/2482234/how-do-i-find-the-mysql-my-cnf-location/9603176