In this article we will see how to reset MySQL root password (when password is lost for example).
You need to be root on the shell. Then we need to restart mysql with the skip-grand-table mode :
1 |
service mysql stop && mysqld_safe --skip-grant-tables & |
Now you can login as root mysql without password and change it, for this we login to the mysql database as root
1 |
mysql -u root mysql |
Then we change the password
1 2 3 |
mysql> update user set password=PASSWORD("thenewpassword") where user="root"; mysql> flush privileges; mysql> exit; |
Now restart the mysql service
1 |
service mysql restart |
Mysql root password is now changed !
Comments (0)