ubuntu 下安装 mysql 启动报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

时间:2021-11-10 19:44:20

环境:

ubuntu LTS 18.04.1
mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64)

初探 linux,按照如下安装完mysql

sudo apt install mysql-server
sudo apt install mysql-client sudo service mysql start

启动报错:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)


放狗搜索,找了老半天也没解决。

最后,解决办法是:

# 切换到root
sudo -i # 还是上面的启动 mysql 命令
service mysql start # 终于出现了喜人的:
* Starting MySQL database server mysqld