User Tools

Site Tools


mysql_lost_rootpass

Changing mysql root password when you have lost the original password.

sudo /etc/init.d/mysql stop

sudo mysqld_safe --skip-grant-tables &

Now type the following command, you should not be prompted for a password when you enter this command

mysql -u root

Now select the database we are going to use with:
use mysql;

Change the password for root user with:

update user set password=PASSWORD("mynewpassword") where User='root';
The flush privileges;
flush privileges;
Now exit out of mysql.
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:
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.txt · Last modified: 2024/05/23 07:26 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki