问题描述
我在 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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!