查看完整版本: 忘記 MySQL 的 root 密碼可以這樣做...


adj 2007-11-29 18:07

忘記 MySQL 的 root 密碼可以這樣做...

<div style="background-color: white; border: 0px; color: #666666; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
如果忘記了 MySQL 的 root 密碼,可以透過以下方法重新設定:</div>
<div style="background-color: white; border: 0px; color: #666666; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
1. 停止 MySQL server。</div>
<div style="background-color: white; border: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
<span style="color: #666666;"># </span><b><span style="color: red;">/etc/init.d/mysql stop</span></b></div>
<div style="background-color: white; border: 0px; color: #666666; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
2. 啟動 MySQL server,並加上 –skip-grant-tables 參數,便可以略過輸入密碼的過程:</div>
<div style="background-color: white; border: 0px; color: #666666; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
#&nbsp;<span style="color: red; font-family: tahoma, arial, helvetica, sans-serif; font-size: medium; font-weight: bold; line-height: normal;">mysqld -u root --skip-grant-tables &amp; mysql</span></div>
<div style="background-color: white; border: 0px; color: #666666; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
3. 用 root 連接到 MySQL server,輸入:</div>
<div style="background-color: white; border: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
<b><span style="color: red;">mysql -u root</span></b></div>
<div style="background-color: white; border: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
<div style="color: #666666;">
4. 進入 MySQL server 後,輸入以下幾行 SQL 語句:</div>
<span style="color: red;">mysql&gt; use mysql;</span><br>
<span style="color: red;">mysql&gt; update user set password=PASSWORD("newpass") where User=’root’;</span><br>
<span style="color: red;">mysql&gt; flush privileges;</span><br>
<span style="color: red;">mysql&gt; quit</span></div>
<div style="background-color: white; border: 0px; color: #666666; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
5. 重新啟動 MySQL 即可。</div>
頁: [1]
查看完整版本: 忘記 MySQL 的 root 密碼可以這樣做...