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

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

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


当前回答

我不能解释,但在kubuntu 12.04.2之后

Sudo apt-get autoremove linux-headers-3.2.0-37 linux-headers-3.2.0-37-generic

它开始起作用了

其他回答

我只是在不得不重新启动生产服务器后遇到了同样的问题。我正在DigitalOcean液滴上运行Debian 8.1 (Jessie)。

这是我解决问题的方法:

检查文件/var/run/mysqld/mysqld.袜子的存在。如果没有,手动创建它,输入touch /var/run/mysqld/mysqld.袜子(这是我必须做的)。 所以MySQL进程可以使用这个文件。通过输入chown mysql /var/run/mysqld/mysqld.sock更改该文件的所有权。 执行完“2”后,输入service MySQL restart或/etc/init.重新启动MySQL服务d / mysql重启。

经过上述步骤后,我的问题得到了解决。我很少遇到这种问题,可能有更好的方法,所以如果需要,请务必提供建设性的反馈:)。

我的服务器存储空间已满,导致Mysql无法启动。从这里得到了灵感。增加高清和重新启动修复了这个问题。

根据我的经验,你需要先检查服务器是否正在运行,然后再尝试配置MySQL。最后一个解决方案是重新安装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.

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

sudo chmod 755 /var/lib/mysql/mysql

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