Last Updated: May 23, 2012

October 21, 2011

How to Reset Your MySQL Password

We’re guessing you’re like the rest of us and have about a dozen and a half different passwords for your server alone. This includes any number of administrative faculties, and if you’re even more like us—God help you—you’ve been keeping all these keys laying about on PostIt notes. Yet another layer deeper into our similar psyches, and we’re guessing you’ve at some point or another lost a life-saving note.

Long story short, if that lost password happened to be your MySQL database security key, you aren’t necessarily up a certain creek without a means of locomotion. In fact, there’s a rather quick way you can retrieve or reset your MySQL password, and without any panicking to boot.

If you’re in just such a situation, use the primer below to totally reset your MySQL password, allowing you to once again return to normalcy:

1.  First, log onto your server via SSH and then root yourself (but not in an Australian way, mates).

$ su

2.  Next you’ll want to bring any MySQL instances that are already running to a screeching halt—that means stop them before going any further. This will, of course, take down any site dependancies, so be sure to do this at non-peak hours for best results.

3.  Boot up your database in safe mode and skip those pesky privilege checks:

# mysql –user=root mysql

4.  Lastly, reset the blasted lost password by recreating the user table for your database with the following commands. You’ll want to replace the string ‘newrootpwd,’ of course, with a password that’s safe, secure, and easy to remember. Obviously the latter has been a problem, so try to do a bit better this time, eh champ?

UPDATE user SET Password=PASSWORD(‘newrootpwd’) WHERE user=’root’;

FLUSH PRIVILEGES;

  1. Now that that’s done, there’s nothing left to do but reset the server and get back to work!

# /etc/init.d/mysql restart

We complained a bit earlier about your lost password—don’t feel bad, we do it to!—but that doesn’t mean you should take the opportunity now to create a laxer, but easier on the memory, keyword. This is your personal database we’re talking about, and remember to always keep it as secure as possible from the ground-up.

We’re guessing you’re like the rest of us and have about a dozen and a half different passwords for your server alone. This includes any number of administrative faculties, and if you’re even more like us—God help you—you’ve been keeping all these keys laying about on PostIt notes. Yet another layer deeper into our similar psyches, and we’re guessing you’ve at some point or another lost a life-saving note.

Long story short, if that lost password happened to be your MySQL database security key, you aren’t necessarily up a certain creek without a means of locomotion. In fact, there’s a rather quick way you can retrieve or reset your MySQL password, and without any panicking to boot.

If you’re in just such a situation, use the primer below to totally reset your MySQL password, allowing you to once again return to normalcy:

1. First, log onto your server via SSH and then root yourself (but not in an Australian way, mates).

$ su

2. Next you’ll want to bring any MySQL instances that are already running to a screeching halt—that means stop them before going any further. This will, of course, take down any site dependancies, so be sure to do this at non-peak hours for best results.

3. Boot up your database in safe mode and skip those pesky privilege checks:

# mysql –user=root mysql

4. Lastly, reset the blasted lost password by recreating the user table for your database with the following commands. You’ll want to replace the string ‘newrootpwd,’ of course, with a password that’s safe, secure, and easy to remember. Obviously the latter has been a problem, so try to do a bit better this time, eh champ?

UPDATE user SET Password=PASSWORD(‘newrootpwd’) WHERE user=’root’;

FLUSH PRIVILEGES;

5. Now that that’s done, there’s nothing left to do but reset the server and get back to work!

# /etc/init.d/mysql restart

We complained a bit earlier about your lost password—don’t feel bad, we do it to!—but that doesn’t mean you should take the opportunity now to create a laxer, but easier on the memory, keyword. This is your personal database we’re talking about, and remember to always keep it as secure as possible from the ground-up.
Popular Links


Tags: mysqlpassworddatabaseserverbadserver securitysecuritydown timepersonal sitesecure serverSSHup timepassword securitypasswordsITIT securitymemorykeywordsecure passwordssafe password 

Post comment:

Items marked by * are required

Find your hosting

Can’t decide what hosting is right for you? Read our Guide on how to pick a Web Hosting Provider.

Read the Buying Guide

Latest reviews

May 21, 2012

Danny

+ 5 5

Hosthero Ltd
Hosthero Ltd

Read full review

May 20, 2012

Brandon Allin

+ 5 5

WebHostingBuzz
WebHostingBuzz

Read full review

May 20, 2012

Banjamin

+ 4.7 4.7

247 Host
247 Host

Read full review

Advertising

Calendar