MySQL數(shù)據(jù)庫(kù)密碼忘記,不用怕!
本文主要介紹的是忘記MySQL數(shù)據(jù)庫(kù)密碼的實(shí)際解決方案,如果在實(shí)際操作中你不小心忘記MySQL數(shù)據(jù)庫(kù)密碼可以說(shuō)是一件十分麻煩的事情,以下的文章就是對(duì)一麻煩事的破解,以下就是文章的主要內(nèi)容描述。
破解本地MySQL數(shù)據(jù)庫(kù)密碼:
Windows:
1.用系統(tǒng)管理員登陸系統(tǒng)。
2.停止MySQL的服務(wù)。
3.進(jìn)入命令窗口,然后進(jìn)入 MySQL的安裝目錄,比如我的安裝目錄是c:\mysql,進(jìn)入C:\mysql\bin
4.跳過(guò)權(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ù)庫(kù)服務(wù)器相關(guān)程序。mysqld-nt.exe是MySQL Daemon數(shù)據(jù)庫(kù)服務(wù)相關(guān)程序。
5.[未驗(yàn)證]
重新打開(kāi)一個(gè)窗口
進(jìn)入c:\mysql\bin目錄,設(shè)置root的新MySQL數(shù)據(jù)庫(kù)密碼
c:\mysql\bin>mysqladmin -u root flush-privileges password "newpassword"
c:\mysql\bin>mysqladmin -u root -p shutdown
將newpassword替換為你要用的root的密碼,第二個(gè)命令會(huì)提示你輸入新密碼,重復(fù)***個(gè)命令輸入的密碼。
5.[驗(yàn)證]或則:
重新開(kāi)打一個(gè)命令提示符的窗口(CMD)
用空MySQL數(shù)據(jù)庫(kù)密碼方式使用root用戶(hù)登錄 MySQL;
- mysql -u root
修改root用戶(hù)的密碼;
- mysql> update mysql.user set password=PASSWORD('新密碼') where User='root';
- mysql> flush privileges;
- mysql> quit
6.停止MySQL Server,用正常模式啟動(dòng)Mysql
7.你可以用新的密碼鏈接到Mysql 了。
Unix&Linux:
1.用root或者運(yùn)行mysqld 的用戶(hù)登錄系統(tǒng);
2.利用kill命令結(jié)束掉mysqld的進(jìn)程;
3.使用–skip-grant-tables參數(shù)啟動(dòng)MySQL Server
- shell>mysqld_safe –skip-grant-tables &
4.為設(shè)置新MySQL數(shù)據(jù)庫(kù)密碼
- shell>mysqladmin -u root flush-privileges password "newpassword"
5.重啟MySQL Server
附錄:
MySQL修改密碼的方法大全:
- mysql> update user set Password=password('newpassword') where User='root';
- 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';
Tag標(biāo)簽: MySQL忘記密碼,MySQL找回密碼,Mysql密碼,修改MySQL數(shù)據(jù)庫(kù)密碼
原文標(biāo)題:MySQL忘記密碼解決方案
連接:http://www.cnblogs.com/visoeclipse/archive/2010/04/06/1705427.html
【編輯推薦】