Mysql 數據庫忘記密碼修改密碼

1、無密碼登錄MySQL

找到MySQL安裝目錄下的 my.ini 文件。

打開文件找到 [mysqld] 後在下一行添加 skip-grant-tables。

2、登錄MySQL服務。

net stop mysql 停止服務器。

net start mysql 啓動服務器。

mysql -uroot -p 登錄服務器。

顯示輸入面膜直接回車(Enter)後登錄。

3、修改密碼

set password for 'root'@'localhost'=password('123456');

4、如果顯示沒有權限則需要授權。

set global read_only=0;(關掉主庫的只讀屬性)

grant all privileges on *.* to 'root'@'localhost' identified by 'root' with grant option;

flush privileges;

set global read_only=1;(讀寫屬性)

flush privileges;

5、重啓數據庫

net stop mysql

net start mysql

 

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