Skip to content
wade.one

wade.one

wade womersley – york based software engineer

  • Home
  • 2010
  • April
  • 12
  • Reset MySQL root password if you forgot it #mysql

Reset MySQL root password if you forgot it #mysql

Posted on April 12, 2010 By Wade No Comments on Reset MySQL root password if you forgot it #mysql
Programming, Support

Just had a need to reset the mysql root login password for a server, did a bit of Googling and found out this is how you do it (I work on Ubuntu so you may have to tinker with the lines slightly depending on your distribution):

  1. Stop the current MySQL instance from running:
    /etc/init.d/mysql stop
  2. Run mysql with –skip-grant-tables
    /usr/bin/mysqld_safe –basedir=/usr –datadir=/var/lib/mysql –user=mysql –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/run/mysqld/mysqld.sock –port=3306 –skip-grant-tables &
  3. Log into mysql, straight into the mysql database
    mysql -u root mysql
  4. Reset the root password.
    UPDATE user SET Password=PASSWORD(‘newrootpassword’) WHERE User=’root’;
  5. Flush privileges
    flush privileges;
  6. Shut down the new running mysql.
    /etc/init.d/mysql stop
  7. Start up mysql as usual.
    /etc/init.d/mysql start

Et voila, you now have a new root password without needing to know the old one!

Share:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit

Related

Comments

comments

Post navigation

❮ Previous Post: xbox360 to get USB storage support – finally!
Next Post: Job Perspective ❯

You may also like

Hardware
Superb VPS (Virtual Private Server) Provider – VPS.net Review
November 18, 2009
Gaming
Epic Games releases Unreal Development Toolkit for FREE
November 7, 2009
Programming
Hidden things, lack of fries and pointless data
September 4, 2009
Programming
Using SSL in RestClient
March 4, 2011

Leave a Reply Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • AI
  • artificial intelligence
  • Ego-centric
  • Events
  • Films
  • Food
  • Gaming
  • Gym
  • Hardware
  • Holidays
  • News
  • PHP
  • Programming
  • Random Stuff
  • Reviews
  • Science
  • SEO
  • Software
  • Software Engineer
  • Support
  • Uncategorized
  • Work

Copyright © 2026 wade.one.

Theme: Oceanly News Dark by ScriptsTown