How to change your mysql root password using command line

Key words and phrases: 
Change MySQL root user password using mysql sql command
Description & Info: 

So you wanna change your root password for mysql, huh?

Follow these instructions and know in your heart that you did it, the Agaric Way....

MySQL stores username and passwords in user table inside MySQL database.

You can directly update password using the following method to update or change password for user root:

1) Login to mysql server, type following command at shell prompt:

$ mysql -u root -p

2) Use mysql database (type command at mysql> prompt):

mysql> use mysql;

3) Change password for user root:

mysql> update user set password=PASSWORD("NEWPASSWORD") where User='root';

4) Reload privileges:

mysql> flush privileges;
mysql> quit

note: NEWPASSWORD should be replaced with desired password, everything else stays the same...

by Dan
Posted on Tue, 2008-06-24 01:36
in
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.