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

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

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


当前回答

一个建议:总是问MySQL问题是什么。在我的例子中,减少/var/log/mysql/error.log,看到这个:

2015-07-28 12:01:48 23224 [ERROR] /usr/sbin/mysqld: unknown variable 'log_slow_queries=/var/log/mysql/mysql-slow.log'
2015-07-28 12:01:48 23224 [ERROR] Aborting

它在抱怨,因为我在my.cnf中未注释此选项,但在注释此选项后,它启动时没有任何问题。

其他回答

对我来说,在CentOS上,我不得不像这样重新启动mariadb服务:

systemctl start mariadb.service

在Ubuntu 18:10 Linode 1GB Ram中,我遇到了这个错误。在检查了/var/log/mysql/error.log之后,我发现了这个:

[注]InnoDB: innodb_empty_free_list_algorithm由于缓冲池大小较小,修改为legacy。为了使用回退,请将缓冲池至少增加到20MB。

我把我的linode升级到2GB,用sudo mysql重新启动mariadb。接下来运行mysql_secure_admin,但是没有为user-as ususl设置根密码,直到更改根用户使用mysql_native_password插件。 不确定,但似乎袜子是创建的,但由于我的VPS内存不足,服务器关闭了。

我不得不说:

sudo /etc/init.d/mysqld start

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.

这个答案很可能会被淹没在这里,但也许有人会偶然发现它。

在我的例子中,SELinux阻止用户/应用程序连接到MySQL (MariaDB)服务器套接字。在RHEL上,如果启用了SELinux,请检查/var/log/audit/audit.log。