无法通过 socket '/var/lib/mysql/mysql.sock' 连接到本地 MySQL 服务器 (2)

2021-11-20 00:00:00 sockets connect mysql

当我尝试连接到 mysql 时出现以下错误:

I am getting the following error when I try to connect to mysql:

无法通过socket'/var/lib/mysql/mysql.sock'连接本地MySQL服务器(2)

这个错误有解决办法吗?其背后的原因可能是什么?

Is there a solution for this error? What might be the reason behind it?

推荐答案

确保你的 mysql 服务正在运行

Ensure that your mysql service is running

service mysqld start

然后,尝试以下操作之一:

Then, try the one of the following following:

(如果你还没有为mysql设置密码)

(if you have not set password for mysql)

mysql -u root

如果您已经设置了密码

mysql -u root -p

相关文章