MySQL Reset User Password Script

1351 ワード

SET PASSWORD FOR 'jeffrey'@'localhost' = PASSWORD('biscuit');
or
How to Update or Change Password for a Single User in MySQL and Reload Privileges
Soumya Sinha
January 17th, 2009
MySQL stores usernames and passwords in the user table inside the MySQL database. You can directly update a password using the following method to update or change passwords:
1) Login to the MySQL server, type the following command at the shell prompt: $ mysql -u root -p
2) Use the mysql database (type commands at the mysql> prompt): mysql> use mysql; 3) Change password for a user: mysql> update user set password=PASSWORD("newpass") where User='YOUR-USER-NAME';
4) Reload privileges: mysql> flush privileges; mysql> quit