A small episode, I want to import the database before deploying the project. But reluctantly forgot the password (password policy is not turned off, the password is too long forgotten...)
vim /etc/my.cnf
Add a line of skip-grant-tables; save and exit
and then execute again systemctl restart mysqld.service
, restart the database
Directly at the back mysql -u root
, log in without password, change the password
顺序执行
use mysql;
update user set authentication_string = password("newPassword") where user="root" ;
flush privileges;//刷新
quit;
Repeat the above vim /etc/my.cnf
steps again , delete and save the skip-grant-tables just now
Then perform systemctl restart mysqld.service
restart the database
re- mysql -u root -p
login, just enter your password, you can log a discovery
If there are any errors, please raise them~ Thank you!