MySQL忘記密碼的正確解決方法
以下的文章主要介紹的是MySQL忘記密碼的正確解決方法,在實(shí)際操作中如果你忘記MySQL密碼是一件很頭痛的事情,這篇文章主要是介紹對MySQL忘記密碼的補(bǔ)救方案,以下就有詳細(xì)內(nèi)容描述,望你會有所收獲。
MySQL忘記密碼解決方案:
破解本地密碼:
Windows:
1.用系統(tǒng)管理員登陸系統(tǒng)。
2.停止MySQL的服務(wù)。
3.進(jìn)入命令窗口,然后進(jìn)入 MySQL的安裝目錄,比如我的安裝目錄是c:\mysql,進(jìn)入C:\mysql\bin
4.跳過權(quán)限檢查啟動(dòng)MySQL,
c:\mysql\bin>mysqld-nt ––skip-grant-tables
或則:c:\mysql\bin>mysqld ––skip-grant-tables
mysqld.exe是微軟Windows MySQL server數(shù)據(jù)庫服務(wù)器相關(guān)程序。mysqld-nt.exe是MySQL Daemon數(shù)據(jù)庫服務(wù)相關(guān)程序。
MySQL忘記密碼解決方案5.[未驗(yàn)證]
重新打開一個(gè)窗口
進(jìn)入c:\mysql\bin目錄,設(shè)置root的新密碼
c:\mysql\bin>mysqladmin -u root flush-privileges password "newpassword"
c:\mysql\bin>mysqladmin -u root -p shutdown
將newpassword替換為你要用的root的密碼,第二個(gè)命令會提示你輸入新密碼,重復(fù)***個(gè)命令輸入的密碼。
5.[驗(yàn)證]或則:
重新開打一個(gè)命令提示符的窗口(CMD)
用空密碼方式使用root用戶登錄 MySQL;
mysql -u root
修改root用戶的密碼;
- mysql> update mysql.user set password=PASSWORD('新密碼') where User='root';
- mysql> flush privileges;
- mysql> quit
6.停止MySQL Server,用正常模式啟動(dòng)Mysql7.你可以用新的密碼鏈接到Mysql 了。
Unix&Linux:
1.用root或者運(yùn)行mysqld 的用戶登錄系統(tǒng);
2.利用kill命令結(jié)束掉mysqld的進(jìn)程;
3.使用–skip-grant-tables參數(shù)啟動(dòng)MySQL Server
shell>mysqld_safe –skip-grant-tables &
4.為root@localhost設(shè)置新密碼
- shell>mysqladmin -u root flush-privileges password "newpassword"
5.MySQL忘記密碼解決方案重啟MySQL Server
附錄:
MySQL修改密碼的方法大全:
- mysql> update user set Password=password('newpassword') where User='root';
- mysql> flush privileges;
- MYSQLADMIN -u root -p PASSWORD mypasswd
可以修改MYSQL文件夾中的MY.INI文件
- mysql> SET PASSWORD FOR myuser@localhost = PASSWORD('mypasswd');
- mysql> GRANT USAGE ON *.* TO myuser@localhost IDENTIFIED BY 'mypassword';
以上的相關(guān)內(nèi)容就是對MySQL忘記密碼解決方案的介紹,望你能有所收獲。
【編輯推薦】