Wednesday, July 11, 2012

How to Change Mysql root password


MySQL Change root Password


There are 2 ways for doing this: 

1. Using mysqladmin
2. Updating using mysql database commands

Using mysqladmin

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

$ mysqladmin -u root password NEWPASSWORD

If there was an old password already set for e.g., oldpwd, you can change it to a new one by following command:

$ mysqladmin -u root -p'oldpwd' password 'newpwd'

Using mysql database shell commands

mysql stores all user information into a user table inside Mysql database. You can directly update the password for a user in this database table. All you need to do is login to the database and fire below command: 

mysql> update user set password=PASSWORD("newpwd") where User='root';
mysql> flush privileges;
mysql> quit

No comments:

Post a Comment