ERROR 2002 (HY000): Can#39;t connect to local MySQL server through socket #39;/var/run/mysqld/mysqld.sock#39; (2)(ERROR 2002 (HY000): 无法通过 socket /var/run/mysqld/mysqld.sock 连接到本地 MySQL 服务器 (2))
问题描述
我在 LAMPwiki/List_of_Ubuntu_releases#Ubuntu_12.04_LTS_.28Precise_Pangolin.29">Ubuntu 12.04 LTS (Precise Pangolin) 然后在 phpMyAdmin.我忘记了密码,现在无法登录.当我尝试通过终端更改密码时,我得到:
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,那么文件不会存在.所以在这种情况下,用
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. So in that case, install it with
sudo apt-get install mysql-server
但是如果mysql-server已经安装并且正在运行,那么你需要检查配置文件.
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中,socket文件配置可能是/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.
这篇关于ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/mysqld.sock' 连接到本地 MySQL 服务器 (2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ERROR 2002 (HY000): 无法通过 socket '/var/run/mysqld/
基础教程推荐
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 无法解决整理冲突 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
