我在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,卸载它或重新安装它。
当前回答
我在mariadb的termux中遇到了这个问题,它解决了我的问题是以下两行命令-
Pkill MySQL
Mysqld_safe -u root
其他回答
我现在遇到了这个问题,并且解决了它。
尽管您安装了mysql-server,但是需要运行守护进程才能使客户机连接到它。
首先检查mysql服务器是否正在运行:
netstat -tap | grep mysql
你应该会看到这样的东西:
$ sudo netstat -tap | grep mysql
tcp 0 0 localhost:mysql *:* LISTEN 6639/mysqld
如果您没有运行服务器,请使用以下命令启动守护进程:
/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.
对我来说是:
打开/etc/mysql/my.cnf或/etc/my.cnf,搜索“bind-address”。结果是127.0.0.1。我将其转换为localhost,因此行结果应该是'bind-address = localhost'。
否则,你应该使用bind-address指令中存在的IP地址运行你的MySQL服务器,即MySQL -h 127.0.0.1。
如果你使用Ubuntu,这可能是特权的问题。
检查您的目录权限。在root组中是不够的,还可以在MySQL写入的目录上使用chmod(例如,/var/run/mysqld/用于创建mysqld. exe)。pid文件)。
这对我很有帮助。
可能是配置文件有问题。我也遇到过类似的问题,但我在网上找不到解决方案。我注意到我有两个my.cnf文件,一个在/etc/mysql,另一个在/etc。 遵循以下步骤:
使用定位my.cnf在您的计算机上检查my.cnf文件。 如果有两个条目,即/etc/my.cnf和/etc/mysql/my.cnf, 将/etc/mysql/my.cnf重命名为其他内容,例如/etc/mysql/my.cnf.old
尝试再次运行MySQL。