How to change the password in MySQL? The following article brings four methods for beginners to change MySQL passwords. I hope it will be helpful to everyone!
(1) First log in to MySQL:
(2) Change the password format to:
The following interface appears to indicate that the modification was successful :##set password for username@localhost = password( 'New password');Be sure not to forget the semicolon at the end,For example: we change the password to 123:
set password for root@localhost = password('123');
The following interface appears to indicate that the modification is successfulUsing mysqladmin, we do not need to log in first, but it needs to be the original password; we can modify it directly. The modified password format is:
mysqladmin -u username -p old password password new password, note that there is no - in front of password, For example: Let’s change the password to 123456:
mysqladmin -uroot -p123 password 123456
(1) First log in to MySQL
(2) Then enter in sequence:
use mysql # 连接权限数据库 update user set password=password('521') where user='root' and host='localhost'; # 改密码 flush privileges; # 刷新权限The following interface appears to indicate that the modification is successful:
1. Close the running MySQL service. win r input:services.mscPress Enter, find MySQL, and manually close the MySQL service
2. Open the DOS window and use the cd command to go to the bin directory of mysql: it is recommended to directly find the bin directory of mysql and enter cmd and press Enter3. Enter
--skip-grant-tables means
mysqld --skip-grant-tablesand press Enter .Skip the permission table authenticationwhen starting the MySQL service.
4.[Related recommendations:Open another DOS window(The DOS window just now cannot be moved), go to the bin directory of mysql.5. Enter mysql and press Enter. If the above modification is successful, a prompt like mysql> will appear directly.
6. Connect to the permission database: use mysql
6. Change password: update user set password=password("123") where user="root";
7. Refresh permissions (required step): flush privileges; (
Don’t forget the semicolon)8.exit or ctrl c to exit and log in again
mysql video tutorial】
The above is the detailed content of Let’s talk about the four ways to change the password in MySQL (take a quick look for beginners). For more information, please follow other related articles on the PHP Chinese website!