错误2002(HY000):无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2)
我在
I installed LAMP on Ubuntu 12.04 LTS (Precise Pangolin) and then set root password on phpMyAdmin. I forgot the password and now I am unable to login. When I try to change password through terminal I get:
ERROR 2002(HY000):无法通过套接字连接到本地MySQL服务器 '/var/run/mysqld/mysqld.sock'(2)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
我该如何解决?我无法打开LAMP,将其卸载或重新安装.
How can I fix this? I am unable to open LAMP, uninstall it or reinstall it.
我曾经遇到过此问题,并通过安装mysql-server
来解决,因此请确保您已安装mysql-server
,而不是mysql-client
或类似的东西其他.
I once had this problem and solved it by installing mysql-server
, so make sure that you have installed the mysql-server
, not the mysql-client
or something else.
该错误表示文件/var/run/mysqld/mysqld.sock
不存在,如果您未安装mysql-server
,则该文件将不存在.但是,如果mysql-server
已经安装并正在运行,则需要检查配置文件.
That error means the file /var/run/mysqld/mysqld.sock
doesn't exists, if you didn't install mysql-server
, then the file would not exist. But if the mysql-server
is already installed and is running, then you need to check the config files.
配置文件为:
/etc/my.cnf
/etc/mysql/my.cnf
/var/lib/mysql/my.cnf
在/etc/my.cnf
中,套接字文件配置可以是/tmp/mysql.sock
,在/etc/mysql/my.cnf
中,套接字文件配置可以是/var/run/mysqld/mysqld.sock
.因此,删除或重命名/etc/mysql/my.cnf
,让mysql使用/etc/my.cnf
,则可以解决问题.
In /etc/my.cnf
, the socket file config may be /tmp/mysql.sock
and in /etc/mysql/my.cnf
the socket file config may be /var/run/mysqld/mysqld.sock
. So, remove or rename /etc/mysql/my.cnf
, let mysql use /etc/my.cnf
, then the problem may solved.