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:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to 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

Software
How to make the governments attempts to view your search history that bit harder (in Chrome)
October 31, 2015
Programming
PHP5.4.3 Available on Dotdeb.org (Installs fine on Ubuntu)
May 22, 2012
Programming
PHP 5.4 Unofficial Ubuntu apt-get available
March 11, 2012
Hardware
Boot Failure Fixing FlowChart Fun
September 1, 2009

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 © 2025 wade.one.

Theme: Oceanly News Dark by ScriptsTown