解決yum方式安裝的MySQL 5.7 root用戶密碼丟失問題

1、沒有輸入或輸入錯誤的root用戶密碼,無法進入數據庫:?
# mysql -uroot -p?
(1)沒有輸入root用戶密碼,直接回車:?
(2)輸入錯誤的root用戶密碼:?
2、強制結束MySQL進程:?
# yum -y install psmisc?
# killall mysqld?
# pkill mysqld?
# ps -ef | grep mysql?
# ss -tunlp | grep 3306?
3、使用mysqld命令,增加--skip-grant-tables參數,跳過權限表,啟動數據庫:?
# mysqld --defaults-file=/etc/my.cnf --user=mysql --skip-grant-tables &?
# ps -ef | grep mysql?
# ss -tunlp | grep 3306?
4、使用mysql命令直接進入數據庫,為root用戶設置新的密碼并刷新權限:?
# mysql?
mysql> use mysql;?
mysql> update user set authentication_string=password('root@1234') where user='root';?
mysql> flush privileges;?
5、重啟數據庫:?
# killall mysqld?
# pkill mysqld?
# ps -ef | grep mysql?
# ss -tunlp | grep 3306?
# systemctl start mysqld?
6、輸入root用戶新設置的密碼root@1234,進入數據庫:?
# mysql -uroot -p
了解更多網絡知識關注:http://www.vecloud.com/
標簽: