不記得 linux/windows中mysql root密碼萬能修改方法

來源:互聯網
上載者:User

如果本地忘記了root密碼 ,可以試試以下方法:

開啟CMD首先停止mysql服務

net stop mysql

進入mysql安裝目錄下的bin檔案夾,然後輸入

mysqld-nt --skip-grant-tables

跳過密碼檢測

然後另外新開啟一個cmd視窗

輸入mysql 直接斷行符號可以以root許可權進入mysql

use mysql

update user set password=password("新密碼") where user="root";

flush privileges;

如果無錯誤提示,密碼 即可更改成功。

linux的處理辦法


介紹一個在所有版本linux的grub上均可以使用的方法:

1、在Grub的引導裝載程式菜單上,選擇你要進入的條目,鍵入 “e” 來進入編輯模式;

2、在第二行(類似於kernel /vmlinuz-2.6.15 ro root=/dev/hda2 ),鍵入”e”進入編輯模式;

3、在句末加上”init=/bin/bash”,斷行符號;

4、按“b”啟動系統。

這樣我們即可獲得一個bash的shell,進入shell後,根分區的掛載模式預設是唯讀,我們要將其改為可寫,否則不能更改root密碼:

mount -no remount,rw /
passwd root
sync
mount -no remount,ro /
reboot

這樣即可成功更改debian的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.