Sunday, May 18, 2008

Changing MySQL root user password using mysql sql command

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 kamal:

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 kamal:
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='kamal';

4) Reload privileges:mysql> flush privileges;mysql> quit
This method you need to use while using PHP or Perl scripting.

No comments: