Jan 29

Ok, now I’ve forgotten MySQL root password a few times and even worse off, after installation I sometimes couldn’t login with the password I set. So, to reset the password, stop mysql, create a text file with the following:

/etc/init.d/mysql stop
vi /tmp/mysql_reset.sql

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;

Now run the below in order to reset the password

mysqld --init-file=/tmp/mysql_reset.sql
 # now give it time (up to 5 minutes), sometimes it may take that long I found. Not sure why, but it sometimes does
 # by the way, I been told the below works better, but never tested it, it should do better
mysqld_safe --init-file=/tmp/mysql_reset.sql &
 # make sure mysql is dead now
ps -A |grep mysql |awk '{print $1}' |while read FN; do kill $FN; sleep 3; kill -9 $FN; done
 # now start mysql service
/etc/init.d/mysql start

One Response to “How to Reset forgotten MySQL root password”

  1. [...] … an attack ad, and several other regulations that the Times has in place for themselves. …How to Reset forgotten MySQL root passwordOk, now I've forgotten MySQL root password a few times and even worse off, after installation I [...]

Leave a Reply

*
preload preload preload