我在Ubuntu 12.04 LTS (Precise穿山甲)上安装了LAMP,然后在phpMyAdmin上设置根密码。我忘记密码了,现在无法登录。当我试图通过终端更改密码时,我得到:

错误2002 (HY000):无法通过套接字连接到本地MySQL服务器 ' / var /运行/ mysqld / mysqld。袜子”(2)

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


当前回答

我用重启mysql解决了这个问题

/etc/init.d/mysql stop

and

/etc/init.d/mysql start

就是这样。

其他回答

检查你是否拥有正确的权限:

sudo chmod 755 /var/lib/mysql/mysql

我也有同样的问题,这个方法对我很有效。这样做之后,我就可以启动MySQL了。

安装mysql-server解决了这个问题

sudo apt-get install mysql-server

对我来说,更新解决了这个问题:

在Ubuntu上:

sudo apt-get update
sudo apt-get upgrade

CentOS:

sudo yum update

This error can also occur if you try to change the directory where the database is stored, but imput the wrong directory in the configuration file (like a typo in the second drive as D instead of the accurate D_). Instead of telling you the typo directory does not exist, it will tell you that you lack permission to access it (leading you to try to change the permissions for the typo directory, which it will let you do). So if you get this error while changing directories, double check the configuration file and make sure you don't have a typo.

发生此问题是因为MySQL服务器未启动。使用以下命令检查活动状态。

service mysql status

如果active状态为stop,请尝试启动MySQL服务器。

service mysql start