RSS

MySQL Change root Password

09 Jul

Mysqladmin command to change root password

To setup root password for first time, use mysqladmin command at shell prompt as follows:

$ mysqladmin -u root password NEWPASSWORD

However, if you want to change (or update) a root password, then you need to use the following command:

$ mysqladmin -u root -p'oldpassword' password newpass

For example, If the old password is root, you can set the new password to root1234, enter:

$ mysqladmin -u root -p'root' password 'root1234'

Change MySQL password for other users

To change a normal user password you need to type (let us assume you would like to change password for particular user arun) the following command:

$ mysqladmin -u arun -p oldpassword password newpass

Changing MySQL root user password using MySQL sql command

This is another method. 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 particular user arun:

Step1 :

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

$ mysql -u root -p

Step2:

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

mysql> use mysql;

Step3:

Change password for user arun, enter:

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

step4:

Finally, reload the privileges:

mysql> flush privileges;
mysql> quit
 
Leave a comment

Posted by on July 9, 2012 in General, MySQL

 

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: