Windows下mysql忘記root密碼的解決方案

來源:互聯網
上載者:User

標籤:style   使用   sp   strong   on   資料   div   bs   ef   

1、 首先檢查mysql服務是否啟動,若已啟動則先將其停止服務,可在開始菜單的運行,使用命令:

net stop mysql 

 

 

 

開啟第一個cmd視窗,切換到mysql的bin目錄,運行命令:

mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 5.1\my.ini" --console --skip-grant-tables

注釋:

該命令通過跳過許可權安全檢查,開啟mysql服務,這樣串連mysql時,可以不用輸入使用者密碼。 

 

 

 

2、開啟第二個cmd視窗,串連mysql:

輸入命令:

mysql -uroot -p

出現:

Enter password:

在這裡直接斷行符號,不用輸入密碼。

然後就就會出現登入成功的資訊, 

 

 

 使用命令:

show databases;

 

 

使用命令切換到mysql資料庫:

use mysql;

使用命令更改root密碼:

UPDATE user SET Password=PASSWORD(‘newpassword‘) where USER=‘root‘;

 

重新整理許可權:

FLUSH PRIVILEGES;

然後退出,重新登入: 

quit

重新登入: 

mysql -uroot -p

出現輸入密碼提示,輸入新的密碼即可登入:

Enter password: ***********

顯示登入資訊: 成功  就一切ok了

Windows下mysql忘記root密碼的解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.