Change and Reset MySQL root Password改變和重置MySQL的root密碼
Other then the ways specified然後其他的方式指定 here這裡 to reset and change the root password for mySQL database in the case that the password is forgotten or lost, the following instructions explain in details the alternative way at the last part of the guide, where no additional file needs to be created:重置和改變了root密碼為MySQL數據庫,在案件的密碼是忘記或遺失,下列指示解釋,在細節的替代方式,在最後部分的指導,如果沒有額外的文件需要創建:
- Login as root to the Windows or Unix-like (Unix, Linux or BSD) machine with the MySQL server.以root身份登錄到Windows或Unix一樣(的Unix , Linux或BSD的)機器與MySQL服務器。
- Stop the MySQL server by using either of the following command:停止MySQL服務器使用的下列命令:
Linux: /etc/rc.d/init.d/mysql stop Linux作業系統:在/ etc / rc.d / init.d /的MySQL的停止
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh stop FreeBSD作業系統:在/ usr / local的/ etc / rc.d / MySQL的- server.sh停止 - Open the mysql server startup script (ie mysql-server.sh - the file executed to start or stop MySQL server.打開MySQL服務器啟動腳本(即MySQL的- server.sh -該文件執行的開始或停止M ySQL服務器。
- Add –skip-grant-tables to the end of the line that contains the mysqld_safe command as its parameter.添加-跳過-贈款表到去年底,該行包含mysqld_safe命令作為參數。
- Start MySQL server with the following command:啟動MySQL服務器與下面的命令:
Linux: /etc/rc.d/init.d/mysql start Linux作業系統:在/ etc / rc.d / init.d /的MySQL的開始
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh start FreeBSD作業系統:在/ usr / local的/ etc / rc.d / MySQL的- server.sh開始 - Alternatively, start the MySQL server directly and skip the editing with the following command:或者,啟動MySQL服務器直接跳到編輯與以下命令:
mysqld_safe –skip-grant-tables & mysqld_safe -跳過-贈款表&
Depending on your path environment, you may need to point to the correct directory where mysqld_safe is instead.根據您的PATH環境,您可能需要指向正確的目錄下mysqld_safe是不是。
- Run the following commands to login as the mysql user and connect to mysql user/permission database:運行下面的命令登錄作為MySQL用戶並連接到MySQL用戶/許可數據庫:
# mysql -u root mysql # MySQL的中美根的MySQL
- Run the update queries to change the MySQL password:運行更新查詢來改變MySQL的密碼:
mysql> UPDATE user SET Password=PASSWORD(’newrootpassword’) WHERE User=’root’; MySQL的>更新用戶設置密碼=密碼( ' newrootpassword ' )其中user = '根' ;
mysql> FLUSH PRIVILEGES; MySQL的>沖水特權;Note: Replace newrootpassword with the new root password for MySQL server.注:取代newrootpassword與新的root密碼為MySQL服務器。 Flush Privileges is needed to making the password change effect immediately.沖水特權,是需要作出更改密碼立即生效。
- Exit mysql database client by typing exit.退出MySQL數據庫的客戶端上鍵入exit 。
- Stop MySQL server with commands listed at step 2.停止MySQL服務器與命令列在第2步。
- Open the mysql server startup script edit in step 3 again and remove the –skip-grant-tables parameter that has been added.打開MySQL服務器啟動腳本編輯在第3步,再刪除-跳過-贈款表參數已添加。
- Start MySQL server by using command from step 5 or 6.啟動MySQL服務器使用命令從步驟5或6 。
For Redhat Linux users, use the following instructions as the root user of Redhat Linux machine:為Redhat的Linux用戶,請使用以下的指示,作為root用戶的版RedHat Linux的機:
- Stop MySQL process by using command:停止MySQL的過程中所使用的命令:
# killall mysqld # killall mysqld
- Start the MySQL server with following options:啟動MySQL服務器與下列選項:
# /usr/libexec/mysqld -Sg –user=root & #是/ usr / libexec / mysqld -雙桂用戶=根&
- Start the MySQL client:啟動MySQL客戶端:
# mysql # MySQL的
You should see the following message:你應該看到以下訊息:
Welcome to the MySQL monitor.歡迎您到MySQL的監察。 Commands end with ; or g.命令結束;或g.
Your MySQL connection id is 1 to server version: 3.xx.xx您的MySQL連接ID是1至服務器版本: 3.xx.xxType ‘help;’ or ‘h’ for help.鍵入'幫助; '或' h '的幫助。 Type ‘c’ to clear the buffer.類型的' C ' ,以清除緩衝區。
mysql> MySQL的>
- Use mysql database:使用MySQL數據庫:
mysql> USE mysql MySQL的>中使用MySQL
You should see the following message:你應該看到以下訊息:
Reading table information for completion of table and column names讀表信息,為完成表和列名
You can turn off this feature to get a quicker startup with -A您可以關閉此功能,以獲得更快的啟動與- 1Database changed數據庫改變
- Then, update the password for the root user with the following command:然後,更新密碼,為root用戶與下列命令:
UPDATE user SET password=password(”newpassword”) WHERE user=”root”;更新用戶設置密碼=密碼( “ newpassword ” )凡用戶= “根” ;
Replace newpassword with your desired password.取代newpassword與您想要的密碼。 You should see the following message:你應該看到以下訊息:
Query OK, 2 rows affected (0.03 sec)查詢確定,二行受影響( 0.03秒)
Rows matched: 2 Changed: 2 Warnings: 0行匹配: 2改變: 2警告: 0Rows affected may be different, but the Query OK should be there.行受影響的可能有所不同,但查詢確定,應該有。
- Flush the database privileges to reload it in order to make the changes effective:刷新數據庫的特權,重新載入它,以使有效的變化:
mysql> flush privileges; MySQL的>沖水特權;
You should get the following result:你應得的結果如下:
Query OK, 0 rows affected (0.02 sec)查詢確定, 0行受影響( 0.02秒)
- Exit the MySQL client by typing exit.退出MySQL客戶端上鍵入exit 。
- Kill the MySQL server process by typing killall mysqld.殺死MySQL服務器的過程中輸入killall mysqld 。
- Then start MySQL again:然後啟動MySQL的再次:
/etc/init.d/mysqld start / etc / init.d /的mysqld啟動
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要說明 :這是一個機器翻譯網頁是“按原樣”提供的擔保。 Machine translation may be difficult to understand.機器翻譯可能很難理解。 Please refer to請參閱 original English article英文原版的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at分享和貢獻,或取得技術的支持和幫助,在 My Digital Life Forums 我的數字生活論壇 . 。
Related Articles相關文章
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3安裝Web服務器在FreeBSD的6.0與2.2的Apache , MySQL 5.0的和PHP 5 -第3部分
- Reset the Root Password of MySQL Server重置root密碼的MySQL服務器
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4安裝Web服務器在Windows XP的Apache2 , php5和mysql4 -第4部分
- Check and Optimize MySQL Database Automatically with Crontab/Cron檢查和優化MySQL數據庫自動與crontab /玉米
- How to Recover and Reset Gmail (Google Account) Password如何恢復和復位的Gmail ( Google帳戶)的密碼
- How to Reset AdSense Password Not Associated with Google Account如何重置AdSense密碼不能與Google相關的帳戶
- How to Reset WordPress Password to Recover Forgotten Secret如何重置的WordPress密碼,以收回被遺忘的秘密
- Change Oracle Database User Password改變Oracle數據庫的用戶密碼
- Apple iPhone Root Password and Mobile User Password蘋果iphone root密碼和移動用戶密碼
- Fix for Munin MySQL Monitoring Plugin Graph Not Showing or Blank修復munin MySQL的監測插件圖無法顯示或空白



















June 6th, 2006 18:18 2006年6月6日18時18分
[...] Alternatively, on any platform, mysql client can be used to set the new password, althought it’s less secure way of resetting the password (detailed instruction here): [...] [ … … ]另外,任何平台上, MySQL客戶端可以用來設置新的密碼,雖然它的安全性較低的方式重設密碼(詳細指示,在這裡) : [ … … ]
July 9th, 2006 12:05 2006年7月9日12時05分
I wanna reset my ZXDSL 831 ADSL Modemn我想重設我的zxdsl 831的ADSL modemn
Plz tell me the way how to reset it plz告訴我如何重置
I need to do that right now我需要這樣做的權利,現在
Best Rgds最佳rgds
dugger(vincitore) dugger ( vincitore )
December 19th, 2006 14:54 2006年12月19日14時54分
[...] Re: Help me retrieve my password Try this link… Change and Reset MySQL root Password [ … … ]回复:幫我找回我的密碼嘗試此連結…變化和重置MySQL的root密碼
April 23rd, 2007 08:23 2007年4月23日8時23分
[...] Change and Reset MySQL root Password » My Digital Life (tags: mysql administration) No Tags Gelesen: 2 / heute: 2 [...] [ … … ]的變化和重置MySQL的root密碼»我的數位生活(標籤: MySQL的政府)沒有標籤gelesen : 2 / heute : 2 [ … … ]
May 5th, 2008 16:52 2008年5月5日16時52分
[...] judulnya), setelah googling cuma dapat cara untuk mereset dan mengganti password MySQL di UNIX-like di sini. [ … … ] judulnya ) , setelah使用Google cuma應該象限定mereset丹mengganti密碼MySQL的直接投資的UNIX一樣,邸四逆。 Wah, perlu sedikit modifikasi ni … Berikut cara2 yang saya lakukan: 1.議員, perlu sedikit modifikasi倪… berikut cara2楊saya lakukan : 1 。 Kill proses MySQL [...]殺死散文MySQL的[ … … ]
July 3rd, 2008 05:46 2008年7月3日5時46分
On ubuntu, command is mysqld_safe –-skip-grant-tables &關於Ubuntu的,指揮是mysqld_safe -跳過-贈款表&
Extra dash is required so mysql can parse it correctly.短跑是額外的要求,以便MySQL的可以解析正確的。