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

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

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


当前回答

我认为当你得到错误的时候

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

我建议你先检查一下mysql守护进程是否在运行…大多数情况下,默认情况下它不会运行。你可以通过/etc/init.检查d / mysqld的地位。

如果它没有运行,那么先启动它:

.../etc/init.d/mysqld start.

我打赌它会110%有效。

其他回答

我也有同样的问题。如果您的MySQL服务被关闭,有时会发生这种情况。

所以你必须开始:

sudo service mysql start
mysqld stop
mysql.server start

如果您的安装是最近的,您应该确认您的安装是否是安装服务器…mysql -服务器- 5.5 . .可能你只安装了“mysql”..这只是客户端而不是服务器。

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服务器可能没有运行。输入mysql确保它运行。服务器启动进入终端。