MySQL FAQs

Time:2021-10-26

reset password
Close MySQL service
sudo /etc/init.d/mysql stop
Run in MySQL safe mode and skip permission verification
sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
Log in to MySQL as root with an empty password
sudo mysql -u root mysql
Update password
update user set Password = PASSWORD('root') where User ='root';
update mysql.user set authentication_string=password('root') where user='root' ;
Refresh permissions
FLUSH PRIVILEGES;
sign out
quit
The password is too simple. (password reset is required above 5.7)8 digits, upper and lower case letters, special symbols
You must reset your password using ALTER USER statement before executing this statement
Enter MySQL configuration item
vim /etc/my.cnf
Skip validation
[mysqld]
add toskip-grant-tables
Change Password
alter user 'root'@'localhost' identified by '#20as3SElksds0ew98';
Refresh permissions
FLUSH PRIVILEGES;

This work adoptsCC agreement, reprint must indicate the author and the link to this article