gpt4 book ai didi

mysql - 重置 MySQL 密码并丢失 mysqld.sock 文件

转载 作者:可可西里 更新时间:2023-11-01 07:34:21 25 4
gpt4 key购买 nike

我正在尝试在我自己的计算机上运行本地 mysql 服务器。我丢失了最初设置的密码。当我尝试连接到 mysql 时,出现以下错误:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

因此我尝试了 these steps重置我的 MySQL 密码,但是行

mysql -u root mysql

返回相同的错误信息:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

运行命令时

mysqladmin -u root -p statusI get the following message:error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

我一直在检查,提到的文件 (/var/run/mysqld/mysqld.sock) 实际上并不存在。我不确定是什么原因造成的。

我在网上尝试了几个解决方案,包括 this , this , thisthis但是这些解决方案都不适合我。我想补充一点,mysql-server 安装在我的机器上。

感谢任何帮助。如果对上述陈述有任何混淆,请接受我的道歉。我试图尽可能多地解释正在发生的事情,但我是一个初学者,我对那里正在发生的事情一无所知。

最佳答案

1) 使用此命令停止 mysql 恶魔进程:

sudo /etc/init.d/mysql stop

2) 使用此命令的 --skip-grant-tables 选项启动 mysqld demon 进程

sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &

Because you are not checking user privs at this point, it's safest to disable networking. In Dapper, /usr/bin/mysqld... did not work. However, mysqld --skip-grant-tables did.

1) 使用此命令启动mysql客户端进程

mysql -u root

2) 从 mysql 提示符下执行此命令以能够更改任何密码

FLUSH PRIVILEGES;

3) 然后重置/更新您的密码

SET PASSWORD FOR root@'localhost' = PASSWORD('password');

4) 如果你有一个可以从任何地方连接的 mysql root 帐户,你还应该这样做:

UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

一旦收到指示查询成功的消息(一个或多个行受影响),刷新权限:

FLUSH PRIVILEGES;

然后停止 mysqld 进程并用经典方式重新启动它:

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

这是从https://help.ubuntu.com/community/MysqlPasswordReset借来的,您还可以检查另一种重置 mysql 密码的方法。

关于mysql - 重置 MySQL 密码并丢失 mysqld.sock 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38095018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com