Search form

Reset the MySQL Root Password

So you don't know your MySQL root password but you do have the root password of the server. Here's a quick way to reset your MySQL root password on the command line:

1. Stop MySQL

$ service mysql stop

2. Start MySQL in safe mode without a password

$ mysqld_safe --skip-grant-tables &

3. Log into your database server without a password, and reset the MySQL root password

$ mysql -uroot
mysql> USE mysql;
mysql> update user set password=PASSWORD("blarblarblar") where User='root';
mysql> flush privileges;
mysql> quit

4. Stop/restart MySQL and log in normally

$ service mysql stop
$ service mysql start
$ mysql -uroot -p

Categories: