User login

How to change your mysql root password using command line

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....

Resolution

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...

Searched words: 
Change MySQL root user password using mysql sql command

Comments

These steps really worked.

These steps really worked. Thanks a lot for these details

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.