Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot start mysqld_safe to reset root password

Tags:

mysql

root

centos

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.

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?

like image 725
John Peden Avatar asked Apr 25 '12 13:04

John Peden


People also ask

How do I reset my grub mode root password?

In the GRUB menu, find the kernel line starting with linux /boot/ and add init=/bin/bash at the end of the line. Press CTRL+X or F10 to save the changes and boot the server into single-user mode. Once booted the server will boot into the root prompt. Type in the command passwd to set the new password.

What do I do if I forgot my MySQL root password?

In the mysql client, tell the server to reload the grant tables so that account-management statements work: mysql> FLUSH PRIVILEGES; Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.


2 Answers

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.

like image 116
MichaelN Avatar answered Nov 15 '22 19:11

MichaelN


mysqld_safe is 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-tables you won't need to specify a username or password.

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 .

like image 25
octern Avatar answered Nov 15 '22 19:11

octern