ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' 。安装后出错
Posted
技术标签:
【中文标题】ERROR 2002 (HY000): Can\'t connect to local MySQL server through socket \'/tmp/mysql.sock\' 。安装后出错【英文标题】:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' . Error after installationERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' 。安装后出错 【发布时间】:2021-05-04 01:54:02 【问题描述】:错误
在 Ubuntu 20.04 中运行 service mysqld status
后,出现错误:
Unit mysqld.service could not be found.
在运行sudo mysql
之后,我得到:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
.
信息
我刚刚用命令安装了 MySQL
sudo apt-get install mysql-server
.
安装过程中没有错误。重新安装没有帮助。我也尝试在配置文件中找到问题,但我没有/etc/my.cnf
。我不确定,是否可以。
systemctl start mysql
没有帮助。
顺便说一句,service mysql status
工作正常并返回active
状态。
【问题讨论】:
文件my.cnf
位于目录/etc/mysql
所以应该是/etc/mysql/my.cnf
这能回答你的问题吗? Can't connect to local MySQL server through socket '/tmp/mysql.sock
【参考方案1】:
已解决的问题。
-
删除
/usr/local/mysql
、/usr/local/bin/mysql
、/usr/bin/mysql
通过重新安装 MySQL
sudo apt-get update
sudo apt-get install mysql-server
【讨论】:
以上是关于ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' 。安装后出错的主要内容,如果未能解决你的问题,请参考以下文章
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) on Mac
ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/var/run/mysqld/mysqld.sock'
FreeBSD ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when I
尝试了一切仍然得到 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (
尝试了一切仍然得到 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (