0

Is is not possible or am I doing something wrong ?

I'd like to connect to local mysql on Google Cloud Shell but I get the classic "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'" when trying simple mysql and "ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)" when trying mysql -h 127.0.0.1.

Just to be clear, I'm not trying to connect to a Cloud SQL instance.

Thanks

Valentin Coudert
  • 1,759
  • 3
  • 19
  • 44
  • Do yu mean you are in the cloud and trying to connect to a MySQL on your local PC – RiggsFolly Jun 08 '17 at 15:00
  • nope, trying to connect to the mysql installed in Cloud Shell. I mean, the `mysql` command is there, so I was hoping to be able to connect to a local database (so I can play a bit before to make changes to some real Cloud SQL instances) – Valentin Coudert Jun 08 '17 at 15:03

2 Answers2

1

So, what @Arne S said worked. Here are just the complete steps I did:

  1. sudo apt-get install mysql-server
  2. sudo /etc/init.d/mysql start
  3. sudo mysql -h 127.0.0.1
  4. it works!
Valentin Coudert
  • 1,759
  • 3
  • 19
  • 44
0

Unless you have installed and started it there is no mysql server running on your cloud shell instance. The mysql client is available to access cloud sql.

If you need it you could try to install mysql-server on cloud shell

 sudo apt-get install mysql-server

In order to set up cloud shell to interact with cloud sql follow the documentation:

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

Arne S
  • 1,004
  • 14
  • 41