Directory
- How to modify a database password
- Method 1: Use the SET PASSWORD command?
- Method 2: Use Mysqladmin??
- Method 3: Edit the user table directly with UPDATE
- Method 4: When you forget the root password, you can do this
- Modify under Windows
- Modified under Linux
How to modify the database password Method 1: Use the SET PASSWORD command?
First log in to MySQL.??
Format:mysql> set password for 用户名 @localhost = password(‘新密码‘); ??
Example:mysql>set password for [email protected] = password(‘123‘);
Method 2: Use Mysqladmin??
Format:mysqladmin -u 用户名 -p 旧密码 password 新密码
Example:mysqladmin -uroot -p123456 password 123
Method 3: Edit the user table directly with UPDATE
First log in to MySQL.??
Mysql> use mysql; ??
Mysql> update user set password=password(‘123‘) where user=‘root‘; ??
Mysql> flush privileges; ??
Method 4: When you forget the root password, you can modify it under Windows
1. Close the running MySQL service.
2. Open the DOS window and go to the mysql\bin directory.
3. Enter the mysqld --skip-grant-tables carriage return. --skip-grant-tablesThis means that when you start the MySQL service, you skip permission table authentication.
4. Open a DOS window again (because the DOS window just can't move), go to the mysql\bin directory.
5. Enter MySQL return and if successful, the MySQL prompt > will appear.
6. Connection Rights database:use mysql;
7. Change Password: update user set password=password("123") where user="root"; (don't forget the last semicolon)
8. Refresh permissions (required steps):flush privileges;
9. Exitquit
10. Log off the system, and then enter, using the username root and the new password just set 123 to log in.
Modified under Linux
Windows also applies. The same principle as the previous method
1. First edit the my.cnf file in the MySQL installation directory: vi my.cnf "NOTE: My.ini is modified under Windows"
2. Locate the [mysqld] line and add a line below it:skip-grant-tables
3. Press esc Enter to :wq save exit
4. Restart Service service mysql restart "Windows needs to open" service "and find MySQL restart"
5. Modify MySQL password set password = password(‘root‘); or use Method 3
6. After you modify the password, you need to change the my.cnf (my.ini) file back to the original.
7. Restart the service. Complete
How to modify a database password