Wednesday, August 3, 2011

Dealing with MySql passwords

1. If the current root password needs to be changed

mysqladmin -u root -pcurrentpassword password newpassword

2. To Setup a root password, if a password was not setup

mysqladmin -u root password NEWPASSWORD

3. Changing the old password by using sql commands

In mysql, user data is kept in the user table of mysql database. Hence it is  possible to directly update or change passwords for users.

Step1. Login to db.

mysql –u root –p

Step2. Use mysql db

mysql> use mysql;

Step3. Change password.

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

Step4. Reload privileges

mysql> flush privileges;

No comments:

Post a Comment