mysql5.7忘記root用戶登錄密碼

1.先關閉mysql服務器

systemctl stop mysqld

 

2.修改配置文件

vi /usr/local/mysql/etc/my.cnf

在 [mysqld]裏面加上

skip-grant-tables

3重新啓動mysql服務器

systemctl start mysqld

4.登錄服務器,此時是免密登錄

mysql -uroot -p

5.修改數據庫root密碼

mysql> alter user root@localhost identified by '123';

6.停止Mysql

systemctl stop mysqld

 

7.修改my.cnf文件

#skip-grant-tables

8.重啓Mysql

systemctl start mysqld

9.用新密碼登錄即可

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