无法在 google 云 shell 中设置 mysql

Unable to setup mysql in google cloud shell

我正在尝试通过云 shell

在云引擎中安装 mysql

我安装了它:

sudo apt-get -y install mysql-server

并设置密码:

sudo mysql_secure_installation

当我输入密码时,我收到这个错误:

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")

我该如何解决这个问题?

正如约翰所说,云 shell 是一个容器。

您应该使用云 shell 登录您的虚拟机

例如,您的 VM 名称是 mysql-server

gcloud compute ssh username@mysql-server

然后进行安装设置。

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