mysql - 错误 2002 (HY000) : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

标签 mysql centos7

我已经安装了 Centos7 更新,删除了 MariaDB 并完成了 MySQL 的全新安装 - 此外,我已经删除并重新安装了它,但每次连接到 mysql -u root -p 时,我都会收到标题错误。此外,我查看了与此相关的其他票证,但仍未取得进展。如果我运行 service mysqld restart 它说“重定向到/bin/systemctl restart mysqld.service”然后挂起。真的不是 Linux 专家,所以不确定是什么原因造成的?

最佳答案

我遇到了同样的问题,在四处挖掘后发现了一些事情。 MariaDB 是 mysql 的直接替代品。在新系统上,mysql 是 MariaDB 客户端(虽然我不清楚这意味着什么)。我检查了服务是否正在运行:

service mysqld status

表示:

Redirecting to /bin/systemctl status mysqld.service mysqld.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead)

也就是说,mysqld服务没有运行。

启动服务对我有用:
`systemctl start mariadb.service`

现在所有 mysql 命令都按预期工作。

为了打结,请在启动时启用该服务:
`systemctl enable mariadb.service`

关于mysql - 错误 2002 (HY000) : Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26163704/

相关文章:

apache - 504网关超时

mysql - 在centos tomcat上运行Spring Boot应用程序报错

php - 给出了mysql bool 值,但结果显示

sql-server - 为什么我不能在 Linux MSSQL 上一行输入我的用户、密码和服务器,但我可以单独输入?

ssh - 有没有办法允许来自 Centos 上特定机器的 SSH?

c++ - libGL 确实存在,但链接器无法找到它 - Qt 4.8.7、CentOS 7.5

PHP 和 MySQL 函数返回

php - 带有 php 的谷歌应用引擎不支持 mysqli

php - 如何检查数据库连接

mysql - SQL 查询搜索 2 个表