mysql忘記root密碼

MySQL啓動參數中有個是 --skip-grant-tables,叫做跳過授權表

1、停止mysqld服務

2、vim /etc/my.cnf

  [mysqld]

  skip-grant-tables

3、重啓mysql

4、進入mysql命令行

  mysql>use mysql

  mysql>update user set password=password('newpassword') where user='root';

  mysql>flush privileges;

  mysql>exit

5、去掉剛在my.cnf中增加的一行

  #skip-grant-tables


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