linux中mysql忘記root密碼,重置密碼

1、修改 /etc/my.cnf 配置文件

   vim /etc/my.cnf 添加 skip-grant-tables

 

2、重啓mysql服務

service mysqld restart

3、輸入用戶,直接回車進去

 

4、進入mysql數據庫

5、修改密碼

update user set authentication_string=password("new password") WHERE user='root' ' and host = 'localhost';

6、去除第一步中的配置 skip-grant-tables,重啓mysql服務就好了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章