Resetting MySQL root password

From D3xt3r01.tk
Jump to navigationJump to search

WHY

Because you forgot or misstyped your password too many times.

HOW

1. Kill the mysql

 /etc/init.d/mysqld stop

or

 Locate your mysql .pid file and do kill -9 `cat /path/to/pid.file`

2. Start again with --skip-grant-tables

3. Start mysqld

sudo -u mysql mysqld --skip-grant-tables &

4. Run mysql

5. Do this:

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

5. \q

6. Kill the mysqld and start it from the init script.