《Mysql學(xué)習(xí)Mysql忘記root密碼怎么辦》要點:
本文介紹了Mysql學(xué)習(xí)Mysql忘記root密碼怎么辦,希望對您有用。如果有疑問,可以聯(lián)系我們。
MYSQL數(shù)據(jù)庫MySQL有時候忘記了root密碼是一件傷感的事,這種情況下,如何重置root的密碼呢?
MYSQL數(shù)據(jù)庫找到并編輯mysql的my.ini配置文件,在mysqld節(jié)點中添加上skip-grant-table. 如下:
MYSQL數(shù)據(jù)庫
# These let you safely reset the lost root password.
skip-grant-table
MYSQL數(shù)據(jù)庫保存好修改,重啟mysql服務(wù).
MYSQL數(shù)據(jù)庫現(xiàn)在就能不需要root密碼的情況下連接上數(shù)據(jù)庫.然后執(zhí)行下面的更新:
MYSQL數(shù)據(jù)庫
USE mysql;
UPDATE USER
SET password = password('yournewpasswordhere')
WHERE USER = 'root'
AND host = 'localhost';
MYSQL數(shù)據(jù)庫這樣root密碼就修改好了,這個時候,將my.ini中的skip-grant-table刪除,再重啟mysql service
MYSQL數(shù)據(jù)庫下面介紹Windows 和 Linux 下的密碼重置方法.
MYSQL數(shù)據(jù)庫windows:
MYSQL數(shù)據(jù)庫 1.以系統(tǒng)管理員身份登陸系統(tǒng).
2.打開cmd-----net start 查看mysql是否啟動.啟動的話就停止net stop mysql.
3.我的mysql安裝在d:\usr\local\mysql4\bin下.
4.跳過權(quán)限檢查啟動mysql.
d:\usr\local\mysql\bin\mysqld-nt --skip-grant-tables
5.重新打開cmd.進(jìn)到d:\usr\local\mysql4\bin下:
d:\usr\local\mysql\bin\mysqladmin -u root flush-privileges password "newpassword"
d:\usr\local\mysql\bin\mysqladmin -u root -p shutdown 這句提示你重新輸密碼.
6.在cmd里net start mysql
7.搞定了.
MYSQL數(shù)據(jù)庫Linux:
MYSQL數(shù)據(jù)庫MySQL root密碼的恢復(fù)方法之一
MYSQL數(shù)據(jù)庫如果忘記了MySQL root密碼,可以用以下方法重新設(shè)置:
MYSQL數(shù)據(jù)庫1. KILL掉系統(tǒng)里的MySQL進(jìn)程;
MYSQL數(shù)據(jù)庫killall -TERM MySQLd
MYSQL數(shù)據(jù)庫2. 用以下命令啟動MySQL,以不檢查權(quán)限的方式啟動;
safe_MySQLd --skip-grant-tables &
MYSQL數(shù)據(jù)庫3. 然后用空密碼方式使用root用戶登錄 MySQL;
MYSQL數(shù)據(jù)庫MySQL -u root
MYSQL數(shù)據(jù)庫4. 修改root用戶的密碼;
MYSQL數(shù)據(jù)庫MySQL> update MySQL.user set password=PASSWORD('新密碼') where User='root';
MySQL> flush privileges;
MySQL> quit
MYSQL數(shù)據(jù)庫重新啟動MySQL,就可以使用新密碼登錄了.
MYSQL數(shù)據(jù)庫MySQLroot密碼的恢復(fù)方法二
MYSQL數(shù)據(jù)庫有可能你的系統(tǒng)沒有 safe_MySQLd 程序(比如我現(xiàn)在用的 ubuntu操作系統(tǒng), apt-get安裝的MySQL) , 下面方法可以恢復(fù)
MYSQL數(shù)據(jù)庫1. 停止MySQLd;
MYSQL數(shù)據(jù)庫sudo /etc/init.d/MySQL stop
(您可能有其它的方法,總之停止MySQLd的運行就可以了)
MYSQL數(shù)據(jù)庫2. 用以下命令啟動MySQL,以不檢查權(quán)限的方式啟動;
MYSQL數(shù)據(jù)庫MySQLd --skip-grant-tables &
MYSQL數(shù)據(jù)庫3. 然后用空密碼方式使用root用戶登錄 MySQL;
MYSQL數(shù)據(jù)庫MySQL -u root
MYSQL數(shù)據(jù)庫4. 修改root用戶的密碼;
MYSQL數(shù)據(jù)庫MySQL> update MySQL.user set password=PASSWORD('newpassword') where User='root';
MySQL> flush privileges;
MySQL> quit
MYSQL數(shù)據(jù)庫重新啟動MySQL
MYSQL數(shù)據(jù)庫/etc/init.d/MySQL restart
MYSQL數(shù)據(jù)庫就可以使用新密碼 newpassword 登錄了.
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/1104.html