mysql_lost_rootpass
This is an old revision of the document!
Changing mysql root password when you have lost the original password.
1 |
sudo /etc/init .d /mysql stop |
1 |
sudo mysqld_safe --skip-grant-tables & |
Now type the following command, you should not be prompted for a password when you enter this command
1 |
mysql -u root |
Now select the database we are going to use with:
1 |
use mysql; |
Change the password for root user with:
1 |
update user set password=PASSWORD( "mynewpassword" ) where User= 'root' ; |
1 |
flush privileges; |
You will now need to stop mysql and then start it again. The commands will vary slightly depending on if you are using CentOS or Ubunut/Debian.
You should see something similar to the following once you have stopped mysql:
1 2 3 4 |
root@linux ~] # service mysqld stop 150404 20:55:28 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld .pid ended Stopping mysqld: [ OK ] [1]+ Done sudo mysqld_safe --skip-grant-tables |
mysql_lost_rootpass.1428181235.txt.gz · Last modified: 2024/05/23 07:26 (external edit)