龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

Mysql 忘記root密碼的完美解決方法

2019.07.10 | 1587閱讀 | 0條評論 | 數(shù)據(jù)庫

一、更改my.cnf配置文件

1.用命令編輯/etc/my.cnf配置文件,即:vim /etc/my.cnf 或者 vi /etc/my.cnf

2.在[mysqld]下添加skip-grant-tables,然后保存并退出

3.重啟mysql服務:service mysqld restart


二、更改root用戶名

1.重啟以后,執(zhí)行mysql命令進入mysql命令行

2.修改root用戶密碼

舊版mysql:

MySQL> UPDATE mysql.user SET Password=PASSWORD('新密碼') where USER='root';

新版mysql:

MySQL> update mysql.user set authentication_string=PASSWORD('root') where User='root';


MySQL> flush privileges;

MySQL> exit

3.把/etc/my.cnf中的skip-grant-tables注釋掉,然后重啟mysql,即:service mysqld restart


贊 (

發(fā)表評論