Home >Backend Development >PHP Tutorial >mysql user change password

mysql user change password

WBOY
WBOYOriginal
2016-07-29 09:00:431263browse

1: Use the SET PASSWORD command
First log in to MySQL.
Format: mysql> set password for username@localhost = password('new password');
2: Use mysqladmin
Format: mysqladmin -u username -p old password password new password
3: Use UPDATE to directly edit the user table
First log in to MySQL.
mysql> use mysql;
mysql> update user set password=password('123') where user='root' and host='localhost';
mysql> flush privileges;
4: When you forget the root password, you can This way
Take windows as an example:
1. Close the running MySQL service.
2. Open the DOS window and go to the mysqlbin directory.
3. Enter mysqld --skip-grant-tables and press Enter. --skip-grant-tables means to skip the permission table authentication when starting the MySQL service.
4. Open another DOS window (because the DOS window just now cannot be moved) and go to the mysqlbin directory.
5. Enter mysql and press Enter. If successful, the MySQL prompt > will appear.
6. Connect to permission database: use mysql;.
6. Change password: update user set password=password("123") where user="root"; (don’t forget to add the semicolon at the end).
7. Refresh privileges (required step): flush privileges;.
8. Quit.
9. Log out of the system, re-enter, and log in using the username root and the new password 123 you just set.

The above introduces how to change the password for mysql users, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn