Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Problem: Missing super user password, no access to the database:
#./mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
Forced to quit database
# ps -ef | grep mysql
# kill -9 44184 43251
Plus skip the permissions table parameters, restart the database
- Plus --skip-grant-tables parameter permission table may be skipped
# ./mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
# ./mysql #不用密码,也能进入数据库
Set a new password to the root user privileges and refresh
root@localhost [(none)]>use mysql;
root@localhost [mysql]>update user set authentication_string=password('root') where user='root';
root@localhost [mysql]>flush privileges;
- password ( 'password'), is the first root password
The previous mysql process kill off, and then you can re-login
# ./mysqld_safe --defaults-file=/etc/my.cnf &
# ./mysql -uroot -proot