ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysqld.

时间:2023-04-01
本文介绍了ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysqld.sock' 连接到本地 MySQL 服务器 (2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 LAMPwiki/List_of_Ubuntu_releases#Ubuntu_12.04_LTS_.28Precise_Pangolin.29">Ubuntu 12.04 LTS (Precise Pangolin) 然后在 phpMyAdmin.我忘记了密码,现在无法登录.当我尝试通过终端更改密码时,我得到:

I installed LAMP on Ubuntu 12.04 LTS (Precise Pangolin) and then set root password on phpMyAdmin. I forgot the password and now I am unable to login. When I try to change password through terminal I get:

ERROR 2002 (HY000): 无法通过套接字连接到本地 MySQL 服务器'/var/run/mysqld/mysqld.sock'(2)

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

我该如何解决这个问题?我无法打开 LAMP、卸载或重新安装.

How can I fix this? I am unable to open LAMP, uninstall it or reinstall it.

推荐答案

我曾经遇到过这个问题,通过安装mysql-server解决了,所以请确认你已经安装了mysql-server,而不是 mysql-client 或其他东西.

I once had this problem and solved it by installing mysql-server, so make sure that you have installed the mysql-server, not the mysql-client or something else.

那个错误意味着文件/var/run/mysqld/mysqld.sock不存在,如果你没有安装mysql-server,那么文件不会存在.所以在这种情况下,用

That error means the file /var/run/mysqld/mysqld.sock doesn't exists, if you didn't install mysql-server, then the file would not exist. So in that case, install it with

sudo apt-get install mysql-server

但是如果mysql-server已经安装并且正在运行,那么你需要检查配置文件.

But if the mysql-server is already installed and is running, then you need to check the config files.

配置文件是:

/etc/my.cnf
/etc/mysql/my.cnf
/var/lib/mysql/my.cnf

/etc/my.cnf中,socket文件配置可能是/tmp/mysql.sock/etc/mysql/my.cnf 套接字文件配置可能是 /var/run/mysqld/mysqld.sock.所以,删除或重命名/etc/mysql/my.cnf,让mysql使用/etc/my.cnf,那么问题就可以解决了.

In /etc/my.cnf, the socket file config may be /tmp/mysql.sock and in /etc/mysql/my.cnf the socket file config may be /var/run/mysqld/mysqld.sock. So, remove or rename /etc/mysql/my.cnf, let mysql use /etc/my.cnf, then the problem may solved.

这篇关于ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysqld.sock' 连接到本地 MySQL 服务器 (2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:如何使用 GROUP BY 在 MySQL 中连接字符串? 下一篇:Mysql 错误 1452 - 无法添加或更新子行:外键约束失败

相关文章