Search code examples
mysqlgoogle-compute-enginegoogle-cloud-shell

Unable to setup mysql in google cloud shell


I'm trying to install mysql in a cloud engine through the cloud shell

I installed it with:

sudo apt-get -y install mysql-server

And set password with:

sudo mysql_secure_installation

when I input the password, I receive this error:

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

How can I fix this?


Solution

  • As John say, Cloud shell is a container.

    You should use cloud shell to login to your vm

    For example, your VM name is mysql-server

    gcloud compute ssh username@mysql-server
    

    Then follow with your install setup.

    Or

    gcloud compute ssh username@mysql-server --command 'sudo apt-get -y install mysql-server'