fortypoundhead.com

Recover MySQL root password

Posted On 2011-04-02 by FortyPoundHead
Keywords: recover lost forgot MySQL root password
Tags: Software Hack/Tweak Tip Tutorial 
Views: 628


It happens from time to time. For me, it happens after being on a long vacation. I forget my password, and the root password. Shame on me. Recovering is simpler than you think!

  1. Open console and stop mysql service
    #/etc/init.d/mysqld stop

  2. Then i run this service without password
    #mysqld_safe --skip-grant-tables
    You can also run it as a background if you would not use another console (shell)
    #mysqld_safe --skip-grant-tables &

  3. Then i open another console and connect to mysql
    #mysql -u root

    output
    mysql>

  4. Next, i setup new password for root user
    mysql> use mysql;
    mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
    mysql> flush privileges;
    mysql> quit

  5. Last step is stop mysql service
    #/etc/init.d/mysqld stop

  6. Finish, and start mysqld and test new password
    #/etc/init.d/mysqld start
    #mysql -u root -p


About the Author

FortyPoundHead has posted a total of 1974 articles.

 


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.162.19.123

Before you can post, you need to prove you are human. If you log in, this test goes away.


Beat With A Stick List Returns: By request, BWASL has returned to the site. Free your rage by telling the world about something that really grinds your gears. Add your beating.



Recent Forum Posts

BWASL returns
dwirch posted on May 13, 2017 at about 15:24 in Site News

BWASL returns
dwirch posted on May 13, 2017 at about 8:46 in Site News

Job Spammer: Balashankar Bose Bose
dwirch posted on May 11, 2017 at about 10:05 in Spammers

Job Spammer: Bharti Jigyasi
dwirch posted on May 11, 2017 at about 7:58 in Spammers

List of Shady Characters
dwirch posted on April 25, 2017 at about 16:39 in Webmaster Stuff

Job Spammer: Bilal Uddin
dwirch posted on April 25, 2017 at about 11:00 in Spammers