我一直在尝试重置我忘记的 mysql root 密码。当我第一次尝试停止 mysqld 服务并尝试 mysqld --skip-grant-tables 时,我收到此错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
(2) 在这里提问同样的问题
最上面的评论说要对 my.conf 文件做一些事情,我在这里找到了它
orpheus@Roedelius:/etc/mysql$ ls
conf.d debian-start my.cnf.fallback mysql.conf.d
debian.cnf my.cnf mysql.cnf
我不知道如何处理 my.cnf 文件。
打开的 my.cnf 文件除了注释之外还有这个 -
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
所以我尝试了相同的方法重新启动我的mysql服务器并停止它,然后使用--skip-grant-tables,但当时我得到了这个错误-
2017-02-10T17:05:44.870970Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-02-10T17:05:44.872874Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-02-10T17:05:44.874547Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists
这里有同样的问题mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists 。我按照最重要的答案步骤执行此操作 mkdir -p/var/run/mysqld
chown mysql:mysql/var/run/mysqld
然后再次尝试使用 --skip-grant-tables 进入 mysql,但现在我收到此错误
orpheus@Roedelius:/$ sudo mysqld_safe --skip-grant-tables &
[2] 17057
orpheus@Roedelius:/$ 2018-08-02T01:11:46.843096Z mysqld_safe Logging to syslog.
2018-08-02T01:11:46.845788Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2018-08-02T01:11:46.859083Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
我的终端现在只是这么说,不允许我输入任何内容。我在 stackoverflow 上找到的所有重置 root 密码的答案都会导致错误,而且我不确定按照修复这些错误的一些说明是否会破坏某些内容。如果您能帮助我解决当前的错误并重置我的 root 密码,我将不胜感激。
最佳答案
这不是错误:您已经启动了 MySQL 服务器。现在您需要与它交谈!
选项:
- 打开另一个终端窗口,然后使用“mysql”进行连接并 更新您的密码,或者
- 通过运行
hohup mysqld_safe --skip-grant-tables &
(如 sudo)使用“nohup”,因为它将返回 控制到您的终端,然后您可以在其中进行连接。
关于php - sudo mysqld_safe --skip-grant-tables & ,/var/lib/mysql 重置 root 密码时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51644313/