CentOs中mysql服務器重置root密碼方法

1. 中止mysql:mysql

service mysqld stop

2. 編輯/etc/my.cnf,在[mysqld]這行後面加上skip-grant-tables ,並保存sql

3. 啓動mysql:ui

service mysqld start

4. 進入mysql:spa

mysql -u root

5. 選取mysql表:rest

use mysql;

6. 重置root密碼:code

update user set Password=PASSWORD('targetpassword') where USER='root';

7. 刷新權限表:blog

FLUSH PRIVILEGES;

8. 退出mysql登陸:ip

quit;

9. 從新編輯/etc/my.cnf,去除開始添加的一行設置skip-grant-tables ,並保存get

10.重啓mysqld:it

service mysqld restart

11. 用剛剛設置好的密碼登陸mysql便可:

mysql -u root -p
相關文章
相關標籤/搜索