3
votes

I'm using Google Cloud SQL 2nd generation and installed cloud-sql-proxy on my local machine.

On my local machine I'd simply connect to 127.0.0.1:3306 and this has been working fine, in NodeJs, Php and using the mysql command line client.

On Google App Engine Managed VM (flexible environment) i'm using unix_socket or socketPath '/cloudsql/MY_PROJECT_ID:us-central1:SQL_INSTANCE' this has been working fine too, in both, Php and NodeJs.

What doesn't work is MySQL Workbench, I can't figure out how to get it to connect. Does it use another protocol or is cloud-sql-proxy for command line only ?

Here is how I start cloud-sql-proxy

this works:

./cloud_sql_proxy \
  -instances=MY_PROJECT:us-central1:MY_SQL_INSTANCE=tcp:3306 \
  -credential_file='/Users/ME/SomeFolder/MY_SERVICE_ACC_KEY.json'

after that I'd use MySQL Workbench to try to connect to 127.0.0.1:3306, but I always get an error :

SSL connection error: socket layer receive error

local PHP, NodeJS and mysql client work though.

Any help would be appreciated

2

2 Answers

4
votes

Ok, I got it working and believe it might be useful for others too:

I couldn't get it working over the tcp connection, but I figured out how to use the socket method running without fuse:

sudo  ./cloud_sql_proxy \
  -dir=/cloudsql \
  -instances=MY_PROJECT:MY_SQL_REGION:MY_SQL_INSTANCE \
  -credential_file='/Users/ME/some_folder/MY_SERVICE_ACC_KEY.json'

couple of things here:

  1. The folder /cloudsql has to already exists e.g. sudo mkdir /cloudsql
  2. Don't mistype that folder name, really don't
  3. Don't specify the tcp port after instances or it will use a tcp connection instead.
  4. sudo is necessary

In MySQL Workbench:

  1. Select Database > Manage Connections...
  2. Under Connection > Connection Method choose Standard (TCP/IP)
  3. Under Parameters set Host: localhost Port:3306 (although I don't think it matters)
  4. Goto Advanced > Others: enter socket=/cloudsql/MY_PROJECT:MY_SQL_REGION:MY_SQL_INSTANCE
  5. Click Test Connection it should as for your username and password, success.
1
votes

This error indicates that MySQL Workbench is requesting an SSL connection, which is not supported via the proxy. The proxy always uses SSL between the local machine and the instance so there's no need to enable SSL at the MySQL protocol level.

Can you try turning off SSL in MySQL Workbench connection settings?