MySQL 无法启动 mysqld_safe 来重置 root 密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10317286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:06:41  来源:igfitidea点击:

Cannot start mysqld_safe to reset root password

centosrootmysql

提问by jcpeden

I installed MySQL and was playing around with the password settings trying to get Wordpress to connect to it. In doing so, I seem to have hashed my root password and now cannot login.

我安装了 MySQL 并尝试使用密码设置,试图让 Wordpress 连接到它。在这样做时,我似乎已经散列了我的 root 密码,现在无法登录。

I'm trying to reset the password by running

我正在尝试通过运行来重置密码

/etc/init.d/mysqld stop

Then

然后

mysqld_safe --skip-grant-tables

Which outputs

哪些输出

Starting mysql daemon with databases from /var/lib/mysql

But then does nothing. It neither succeeds nor fails. I've not got any databases setup so I'd be happy to remove and reinstall mysql if necessary but I tried that to no avail. How can I get back in?

但随后什么也不做。它既不成功也不失败。我没有设置任何数据库,因此如果需要,我很乐意删除并重新安装 mysql,但我尝试了无济于事。我怎样才能回去?

回答by octern

mysqld_safeis the command to start the mysql engine. It's not supposed to do or show anything after the line saying that it's started mysql. Once you've run mysqld_safe, the next step is to run mysql. Because you started mysqld with --skip-grant-tablesyou won't need to specify a username or password.

mysqld_safe是启动mysql引擎的命令。在说它已启动 mysql 的行之后,它不应该做或显示任何内容。运行后mysqld_safe,下一步就是运行mysql。因为你是用 mysqld 启动的,--skip-grant-tables所以不需要指定用户名或密码。

You can then give the command to reset root's password. For instructions on how to set a password, see http://dev.mysql.com/doc/refman/5.0/en/set-password.html.

然后,您可以发出命令来重置 root 的密码。有关如何设置密码的说明,请参阅http://dev.mysql.com/doc/refman/5.0/en/set-password.html

回答by MichaelN

have you tried "mysqld --skip-grant-tables" instead of mysqld_safe? make sure to kill any mysqld threads that didn't die before starting mysqld --skip-grant-tables. Do a ps -ef and grep for mysql, kill -9 any mysql process, then start it --skip-grants-tables.

您是否尝试过“mysqld --skip-grant-tables”而不是 mysqld_safe?确保在启动 mysqld --skip-grant-tables 之前杀死所有没有死掉的 mysqld 线程。为 mysql 执行 ps -ef 和 grep,杀死 -9 任何 mysql 进程,然后启动它 --skip-grants-tables。