Mysql – ERROR 2003 (HY000): Can’t connect to MySQL server on ‘xxx.xxx.xx.xx’ (10060)

google-cloud-sqlmysql-5.7mysql-workbench

I'm trying to connect my local MySQL workbench to a 2nd generation MySQL instance on Google SQL platform using the following command on my windows laptop.

mysql --host=130.xxx.xx.xx --port=3306 --user=root --password

I have also created a user in the MYSQL from the Google Cloud shell and created a 'cwood' user and granted all permissions

 mysql --host=130.xxx.xx.xx --port=3306 --user=cwood --password

should the username be cwood@something?

I double checked my IP address with whatismyIPaddress it is granted permission in the allowed network section.

I can connect via Google Cloud Shell on the Google Platform itself using root and also ping the IP address from the local cmd prompt and ping my machine from google shell.

As a troubleshooting step I have disabled the local firewalls on my laptop and granted full access to 0.0.0.0/0 to allow all connections on the google platform console so dont think this is the issue.

still no joy from either a cmd line connection on windows or using a putty client, can anyone give me any further pointers on the missing step? something like allow remote connections? being a managed service I dont have the local config files, ip tables as many google searches suggest

Cheers..

Best Answer

I had a similar issue. I believe there are two ways to resolve it (though only one worked for me).

The first way (that did not work for me) would be to create a client certificate via the Cloud Platform -> SQL -> [Instance] -> Access Control tab -> SSL tab -> Create Client Certificate button.

It will give you instructions for downloading the client certificate to your machine and using it to connect via SSL.

The second way (which did work for me) was to allow non-SSL connections. You can find the button in the the "SSL Connections" section under the same SSL tab (under Access Control for the instance). Then try connecting with gcloud sql connect [instance-name] --user=root. This will automatically send a request to allow your IP address to connect directly to the database, and then attempt to connect via the mysql tool.