我在Ubuntu 12.04 LTS (Precise穿山甲)上安装了LAMP,然后在phpMyAdmin上设置根密码。我忘记密码了,现在无法登录。当我试图通过终端更改密码时,我得到:
错误2002 (HY000):无法通过套接字连接到本地MySQL服务器 ' / var /运行/ mysqld / mysqld。袜子”(2)
我该如何解决这个问题?我无法打开LAMP,卸载它或重新安装它。
我在Ubuntu 12.04 LTS (Precise穿山甲)上安装了LAMP,然后在phpMyAdmin上设置根密码。我忘记密码了,现在无法登录。当我试图通过终端更改密码时,我得到:
错误2002 (HY000):无法通过套接字连接到本地MySQL服务器 ' / var /运行/ mysqld / mysqld。袜子”(2)
我该如何解决这个问题?我无法打开LAMP,卸载它或重新安装它。
当前回答
在我的情况下,我不能访问mysql,经过3天的研究,我有一个解决方案。这是一个完美的解决方案,因为我已经搜索了/var/run/mysqld/mysqld.我和袜子没有找到文件夹。可以在putty上执行以下命令。
sudo mkdir /var/run/mysqld/
sudo chown -R mysql:mysql /var/log/mysql
sudo mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --socket=/var/run/mysqld/mysqld.sock
sudo /etc/init.d/mysql restart
你会节省宝贵的时间。
其他回答
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 service mysql restart
这对我很管用。
以下是对我有效的方法:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
service mysql restart
这将创建一个链接。
在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内存不足,服务器关闭了。
您可以首先检查服务是否正在运行,使用:
ps ax | grep mysql
我得到了这样的回答:
6104 pts/0 S 0:00 /bin/sh /usr/bin/mysqld_safe
6431 pts/0 Sl 0:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/var/run/mysqld/m
没有响应意味着服务没有运行,请执行以下操作:
service mysql start