mysql 資料庫忘記密碼【轉載】

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   使用   ar   資料   art   

在windows環境下

1.殺死所有的mysql進程

      a.通過dos命令:net start 與net stop mysql

      b.通過控制台的服務

2.在dos的提示框內,將路徑定位到mysql的安裝目錄下如:c:\mysql\bin

     在控制台輸入:mysqld  --skip-grant-tables    //越過root許可權

     斷行符號後,沒有任何顯示,表示成功

3.重新開啟一個dos提示框,在框內輸入mysql -u root -p 進行無密碼登陸

4.對mysql的密碼進行修改

   輸入如下命令

    >use mysql 

    >update user set password=password("new_pass") where user="root"; 

    >flush privileges; 

    也可以這樣:mysqladmin -h hostname -u user password ‘new password‘‘。

    在載入許可權`mysqladmin -h hostname flush-privileges‘ ,或者使用 SQL 命令`flush privileges‘。 

5.退出

   輸入\q

6.重新進入以新修改的密碼進入mysql



在linux環境下:

  1.終端輸入 vi  /etc/my.cnf

     斷行符號,進入修改,在[mysqld]段中加入

     skip-grant-tables儲存退出

   2.重啟mysql的服務

       service mysqld restart

   3.登入mysql

      終端輸入:mysql斷行符號登入

      進入mysql後,輸入:

      use mysql;

      update user set password=password(‘new password‘) where user=‘root‘;

      flush privileges;

      quit;

      退出mysql

   4.再次進入vi  /etc/my.cnf

      修改回原來的狀態,去掉skip-grant-tables,儲存退出

   5.重啟mysql服務

        service mysqld restart,用新密碼登入

轉載url:http://mrhouzhibin.blog.163.com/blog/static/1945962412011926112959446/

mysql 資料庫忘記密碼【轉載】

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.