Reset the Root Password of MySQL Server重置root密碼的MySQL服務器

By default, MySQL Server will be installed with root superuser without any password.默認情況下, MySQL服務器將被安裝以root超級無任何密碼。 You can connect to MySQL server as root without requiring password or by keying in blank password.您可以連接到MySQL服務器,以root的身份,而不需要密碼或由鍵控在空白密碼。 However, if you have set the password for root and forget or unable to recall the password, then you will need to reset the root password for MySQL.不過,如果您有設定密碼為根,忘記或無法記得密碼,然後您將需要重置root密碼為MySQL開發。

MySQL Reference Manual has detail steps on how to reset password for root which are as below: MySQL的參考手冊有詳細的步驟,就如何重設密碼為根,這是作為如下:

The procedure under Windows:程序在Windows下:

  1. Log on to the Windows system where MySQL is running as Administrator.登錄到Windows系統的情況下運行的MySQL管理員。
  2. Stop the MySQL server if it is running.停止MySQL服務器,如果它正在運行。 For a server that is running as a Windows service, go to the Services manager:一台服務器正在運行作為Windows服務,轉到服務經理:

    Start Menu -> Control Panel -> Administrative Tools -> Services開始菜單-> “控制面板- >”管理工具“- >服務

    Then find the MySQL service in the list, and stop it.然後找到MySQL的服務列表中,並阻止它。

    If your server is not running as a service, you may need to use the Task Manager to force it to stop.如果您的服務器運行的不是作為一種服務,您可能需要使用任務管理,迫使它停止。

  3. Create a text file and place the following command within it on a single line:創建一個文本文件,把下面的命令與它在一個單一的路線:

    SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’MyNewPassword’);設置密碼為'根' @ '本地' =密碼( ' mynewpassword ' ) ;

    Save the file with any name.保存該文件以任何名義。 For this example the file will be C:\mysql-init.txt.在這個範例中的文件將是C : \ MySQL的- init.txt 。

  4. Open a console window to get to the DOS command prompt:打開一個控制台窗口,以獲得向DOS命令提示符下:

    Start Menu -> Run -> cmd開始菜單-> “運行- >” c m d

  5. If MySQL is installed in C:\mysql.如果MySQL的安裝在C : \ MySQL的。 If MySQL is installed in another location, adjust the following commands accordingly.如果MySQL的是安裝在另一個位置,調整下列命令。

    At the DOS command prompt, execute this command:在DOS命令提示符下,執行此命令:

    C:\> C:\mysql\bin\mysqld-nt –init-file=C:\mysql-init.txt為C : \ >為C : \ MySQL的\斌\ mysqld - NT下的init文件=為C : \ MySQL的- init.txt

    The contents of the file named by the –init-file option are executed at server startup, changing the root password.該文件的內容命名- init的文件選項是執行在服務器啟動,改變了root密碼。 After the server has started successfully, you should delete C:\mysql-init.txt.之後,服務器已成功啟動,您應該刪除為C : \ MySQL的- init.txt 。

    If you installed MySQL using the MySQL Installation Wizard, you may need to specify a –defaults-file option:如果您安裝了MySQL使用MySQL安裝嚮導,您可能需要指定一個-默認文件選項:

    C:\> “C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt.exe”為C : \ >的“ C : \程序文件\ MySQL的\ MySQL服務器5.0 \斌\ mysqld - nt.exe ”
    –defaults-file=”C:\Program Files\MySQL\MySQL Server 5.0\my.ini” -默認文件= “為C : \程序文件\ MySQL的\ MySQL服務器5.0 \ my.ini ”
    –init-file=C:\mysql-init.txt - init的文件=為C : \ MySQL的- init.txt

    The appropriate –defaults-file setting can be found using the Services Manager:適當-默認文件設置可發現使用的服務經理:

    Start Menu -> Control Panel -> Administrative Tools -> Services開始菜單-> “控制面板- >”管理工具“- >服務

    Find the MySQL service in the list, right-click on it, and choose the Properties option.找到MySQL的服務列表中,右鍵單擊它,選擇屬性選項。 The Path to executable field contains the –defaults-file setting.路徑的可執行字段包含-默認文件的設置。 Be sure to supply the –init-file argument with the full system path to the file, regardless of your current working directory一定要供應- init的文件的說法與完整的系統文件的路徑,無論您的當前工作目錄

  6. Stop the MySQL server, then restart it in normal mode again.停止MySQL服務器,然後重新啟動它在正常模式下一次。 If the MySQL server is ran as a service, start it from the Windows Services window.如果MySQL服務器是然作為一個服務,啟動它從Windows服務的窗口。 If you start the server manually, use whatever command you normally use.如果你啟動服務器手動,使用什麼命令,通常您可使用。
  7. Connect to MySQL server by using the new password.連接到MySQL服務器使用新的密碼。

For Unix environment, the procedure for resetting the root password is as follows:為Unix環境,程序重置root密碼是如下:

  1. Log on to the Unix system as either the Unix root user or as the same user that the mysqld server runs as.登錄到UNIX系統作為Unix的root用戶或為同一用戶認為mysqld服務器運行。
  2. Locate the .pid file that contains the server’s process ID.找到。 PID的檔案,其中包含了服務器的進程ID 。 The exact location and name of this file depend on your distribution, hostname, and configuration.確切的位置和名稱,此文件取決於您的分佈,主機名稱,和配置。 Common locations are /var/lib/mysql/, /var/run/mysqld/, and /usr/local/mysql/data/.常見的地點是到/ var / lib / MySQL的/和/ var /運行/ mysqld / ,和/ usr / local / MySQL的/數據/ 。 Generally, the filename has the extension of .pid and begins with either mysqld or the system’s hostname.一般來說,文件名的擴展。 PID控制,並開始與任何mysqld或系統的主機名。

    Stop the MySQL server by sending a normal kill (not kill -9) to the mysqld process, using the pathname of the .pid file in the following command:停止MySQL服務器發送一個正常的殺(不殺-9 )到mysqld過程中,使用的路徑的。 PID的文件在以下命令:

    shell> kill `cat /mysql-data-directory/host_name.pid`蜆殼>殺人`貓/ mysql-data-directory/host_name.pid `

    Note the use of backticks rather than forward quotes with the cat command; these cause the output of cat to be substituted into the kill command.注意使用backticks ,而非提出的報價與貓的指揮;這些事業的輸出貓被替換成KILL命令。

  3. Create a text file and place the following command within it on a single line:創建一個文本文件,把下面的命令與它在一個單一的路線:

    SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’MyNewPassword’);設置密碼為'根' @ '本地' =密碼( ' mynewpassword ' ) ;

    Save the file with any name.保存該文件以任何名義。 For this example the file will be ~/mysql-init.在這個範例文件將〜 / MySQL的-的init 。

  4. Restart the MySQL server with the special –init-file=~/mysql-init option:重新啟動MySQL服務器與特殊的init文件= 〜 / MySQL的- init的選項:

    shell> mysqld_safe –init-file=~/mysql-init &蜆殼> mysqld_safe - init的文件= 〜 / MySQL的-的init &

    The contents of the init-file are executed at server startup, changing the root password.內容的Init文件的執行在服務器啟動,改變了root密碼。 After the server has started successfully you should delete ~/mysql-init.之後,服務器已成功啟動您應該刪除〜 / MySQL的-的init 。

  5. Connect to MySQL server by using the new password.連接到MySQL服務器使用新的密碼。

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另外,任何平台上, MySQL客戶端可以用來設置新的密碼,雖然它的安全性較低的方式重設密碼(詳細指示 here這裡 ): ) :

  1. Stop mysqld and restart it with the –skip-grant-tables –user=root options (Windows users omit the –user=root portion).停止mysqld並重新啟動它與-跳過-贈款表用戶=根選項( Windows用戶省略-用戶=根部分) 。
  2. Connect to the mysqld server with this command:連接到mysqld服務器與此命令:

    shell> mysql -u root蜆殼> MySQL的中美根

  3. Issue the following statements in the mysql client:發出以下聲明在MySQL客戶端:

    mysql> UPDATE mysql.user SET Password=PASSWORD(’newpwd’) MySQL的>更新mysql.user設置密碼=密碼( ' newpwd ' )
    -> WHERE User=’root’; -> “其中u ser= '根' ;
    mysql> FLUSH PRIVILEGES; MySQL的>沖水特權;

    Replace ‘newpwd’ with the actual root password that you want to use.取代' newpwd '與實際root密碼您想要使用的。

  4. You should be able to connect using the new password.您應該可以連接使用新的密碼。

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 我的數字生活論壇 .



9 Responses to “Reset the Root Password of MySQL Server” 9回應“重置root密碼的MySQL服務器”

  1. Change and Reset MySQL root Password » My Digital Life改變和重置MySQL的root密碼»我的數位生活
    June 6th, 2006 18:12 2006年6月6日18時12分
    1

    [...] 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數據庫,在案件的密碼是忘記或遺失,下列指示解釋,在細節的替代方式,在上次的一部分,指導,凡沒有額外的文件需要建立: [ … … ]

  2. Mike Scalora麥克斯卡洛拉
    October 8th, 2007 03:47 2007年10月8日3時47分
    2

    You should add –verbose –console to the command in step 5.你應該添加-詳細-控制台命令在第5步。 I got a error because of a copy and paste issue that include a quote of the wrong type but there’s no error feedback without the –console.我得到錯誤,因為一個複製並粘貼的問題,包括引用了錯誤的類型,但有沒有錯誤的反饋意見,未經控制台。 Also, the -console to stop the server with CTRL-C under windows, not sure about linux.此外,控制台停止服務器與按Ctrl - C的Windows環境下,不知道的Linux 。

    -Mike -麥克

  3. Roar注重成果的年度報告
    April 23rd, 2008 23:38 2008年4月23日23時38分
    3

    This isn’t correct.這是不正確的。 The syntax should be “–init” not “-init”.語法應該是“ - init的”不“ -的init ” 。

  4. Roar注重成果的年度報告
    April 23rd, 2008 23:39 2008年4月23日23時39分
    4

    Ah and now that I’ve posted I see the problem.啊,現在我已張貼我看到這個問題。 This site is disallowing double “-”.這個站點是不允許的雙重“ -” 。 It’s being escaped or something.它的被逃脫或東西。

    Well dear reader, just now that “-init” should have TWO dashes (hyphens), not one.以及親愛的讀者,只是現在“的init ”應該有兩個破折號(連字號) ,而不是1 。

  5. Roar注重成果的年度報告
    April 23rd, 2008 23:39 2008年4月23日23時39分
    5

    Gah. gah 。 “know” not “now”. “知道” ,而不是“現在” 。 I’m going for coffee now.我會為現在的咖啡。

  6. Rob白俄羅斯共和國
    April 24th, 2008 10:05 2008年4月24日10時05分
    6

    Dude,紈絝子弟,

    Didn’t see these comments while reading the article, but I figured out the double-hyphen syntax by trial and error.沒有看到這些評論的同時,讀文章,但我揣摩雙連字符語法審判和錯誤。
    Anyway you saved my Life by putting this documentation on the Net !!無論如何,你救了我的生活把這個文件就淨! A thousand thanks ! 1000謝謝! -Rob -白俄羅斯共和國

  7. Dan王丹
    April 25th, 2008 01:37 2008年4月25日1時37分
    7

    There is a typo on the mysqld startup script.有一個錯字就啟動腳本mysqld 。

    The correct command requires TWO dashes before the parameter setting.正確的命令需要兩個破折號之前的參數設置。

    The correct command is (note TWO dashes before skip-grant-tables):正確的命令是(請注意,兩個破折號之前跳過-贈款表) :

    mysqld_safe –skip-grant-tables mysqld_safe -跳過-贈款表

  8. Kamal BAKOUR卡邁勒bakour
    July 31st, 2008 21:18 2008年7月31日21時18分
    8

    Procdure to reset root password in MySQL [RedHat & Fedora] procdure重置root密碼在MySQL [版RedHat & Fedora的]

    ====================================================== ================================================== ====
    Step-1步驟- 1
    [root@redhat~]#killall mysqld [根@ Redhat的〜 ] # killall mysqld
    [root@redhat~]#/usr/libexec/mysqld –skip-grant-tables –user=root & [根@ Redhat的〜 ] #是/ usr / libexec / mysqld -跳過-贈款表用戶=根&

    ====================================================== ================================================== ====
    Step-2 (In MySQL)步驟- 2 (在MySQL )
    [root@redhat~]#mysql [根@ Redhat的〜 ] # MySQL的
    use mysql;使用MySQL ;
    update user set password=password(”newpassowrd”) where user=”root”;更新用戶設置密碼=密碼( “ newpassowrd ” )凡用戶= “根” ;
    flush privileges;沖水特權;
    exit;退出;

    ====================================================== ================================================== ====
    Step-3步驟- 3
    [root@redhat~]#killall mysqld [根@ Redhat的〜 ] # killall mysqld
    [root@redhat~]#/etc/init.d/mysqld start [根@ Redhat的〜 ] # / etc / init.d /的mysqld啟動

    There you go在那裡,您去 : )

  9. Jose聖荷西
    August 14th, 2008 10:47 2008年8月14日10時47分
    9

    phpmyadmin

Leave a Reply離開的答复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用這些標籤: href=""的<a title=""> <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> <刪除日期時間= “ ” >的<em>的<i> <q cite=""> <strike>的<strong>

Subscribe without commenting訂閱無評論


Custom Search

New Articles新的條款,

Incoming Search Terms for the Article傳入的搜索條件文章

reset mysql password 重置MySQL的密碼 - - mysql forgot password MySQL的忘記密碼 - - mysql forgot root password MySQL的忘記了root密碼 - - MySQL remove root password MySQL中刪除root密碼 - - remove mysql password 刪除MySQL的密碼 - - mysql default password MySQL的默認密碼 - - mysql reset password MySQL的重設密碼 - - mysql reset root password MySQL的root密碼重置 - - xampp mysql password xampp MySQL的密碼 - - forget mysql password 忘記MySQL的密碼 - - mysql remove password MySQL的刪除密碼 - - mysql reset root MySQL的重置根 - - default mysql password MySQL的默認密碼 - - reset password mysql 重設密碼的MySQL - - ubuntu mysql root password Ubuntu的MySQL的root密碼 - - xampp default password xampp預設密碼 - - remove mysql root password 刪除MySQL的root密碼 - - remove password mysql 刪除密碼的MySQL - - lost mysql password windows 失去了MySQL的密碼Windows - - mysql password reset MySQL的密碼重置 - - reset xampp password 重設密碼xampp - - xampp reset password xampp重設密碼 - - recover mysql password 收回的MySQL密碼 - - resetting mysql password 重置MySQL的密碼 - - forgot password mysql 忘記密碼的MySQL - - mysql lost password windows MySQL的遺失密碼的Windows - - mysql forget password MySQL的忘記密碼 - - mysql root password recovery MySQL的root密碼復甦 - - xampp forgot password xampp忘記密碼 - - resetting mysql root password 重置MySQL的root密碼 - - mysql password forgot MySQL的密碼忘了 - - xampp reset mysql password xampp重置MySQL的密碼 - - delete mysql password 刪除MySQL的密碼 - - reset mysql password windows 重置MySQL的密碼Windows - - Recover MySQL root password Windows 收回MySQL的root密碼的Windows - - removing mysql password 刪除MySQL的密碼 - - reset mysql root password windows 重置MySQL的root密碼的Windows - - how to remove mysql password 如何刪除MySQL的密碼 - - reset mysql root 重置MySQL的根 - - how to reset MySQL password 如何重置MySQL的密碼 - - forgot mysql root password 忘了MySQL的root密碼 - - remove root password mysql 刪除root密碼的MySQL - - mysql forgotten password MySQL的忘記你的密碼 - - find mysql password 找到MySQL的密碼 - - xampp mysql root password xampp MySQL的root密碼 - - mysql password recovery MySQL的密碼恢復 - - mysql recover root password MySQL的恢復root密碼 - - forget password mysql 忘記密碼的MySQL - - mysql password windows MySQL的密碼Windows - - xampp mysql default password xampp MySQL的默認密碼 - - reset root password mysql 重置MySQL的root密碼 - - reset root password mysql windows 重置MySQL的root密碼的Windows - - mysql reset root password windows MySQL的重置root密碼的Windows - - mysql password forget MySQL的密碼忘記 - - mysql 5 default password MySQL的5預設密碼 - - forgot password for mysql 忘記密碼同時為MySQL開發 - - mysql removing root password MySQL中刪除root密碼 - - recover mysql password windows 收回的MySQL密碼Windows - - mysql windows lost password MySQL中的Windows遺失密碼 - - windows mysql password 在Windows MySQL的密碼 - - all 全部 - - forgot xampp password 忘記密碼xampp - - xampp default mysql password xampp默認的MySQL密碼 - - mysql 5.0 default password MySQL 5.0的默認密碼 - - mySQL recover password windows MySQL的恢復密碼Windows - - reset mysql root password 重置MySQL的root密碼 - - recover mysql root password 收回MySQL的root密碼 - - remove password in mysql 刪除密碼在MySQL - - xampp password mysql xampp密碼的MySQL - - mysql 5 reset root password MySQL的五重設root密碼 - - removing mysql root password 刪除MySQL的root密碼 - - xampp password reset xampp密碼重置 - - removing root password mysql 刪除root密碼的MySQL - - reset mysql password xampp 重置MySQL的密碼xampp - - mysql5 default password mysql5的默認密碼 - -