乾貨----004----MySQL忘記root密碼怎麼辦?

來源:互聯網
上載者:User

標籤:

MySQL忘記root密碼怎麼辦?

MySQL忘記root密碼怎麼辦?一般情況下會有兩種思路:找回密碼和重設密碼。在實際的工作中,MySQL資料庫忘記root密碼一般採用重設密碼的辦法去解決。下面就看看在Linux下和在Windows下重設root密碼的步驟。

Windows下MySQL忘記root密碼怎麼辦?
1.以系統管理員身份登陸系統,啟動mysql跳過許可權檢查.
d:\mysql\bin\mysqld-nt –skip-grant-tables

2.進到d:\mysql\bin下,使用mysqladmin命令設定密碼
d:\mysql\bin\mysqladmin -u root flush-privileges password “新密碼”

3.在cmd裡重新啟動mysql
net start mysql

Linux下MySQL忘記root密碼怎麼辦?
1. 用以下命令啟動MySQL,以不檢查許可權的方式啟動;
[[email protected] mysql]# safe_MySQLd –skip-grant-tables &
[[email protected] mysql]# MySQLd –skip-grant-tables &

2. 然後用空密碼方式使用root使用者登入MySQL
[[email protected] mysql]# MySQL -u root

3. 修改root使用者的密碼;
MySQL> update MySQL.user set password=PASSWORD(‘新密碼’) where User=’root‘;
MySQL> flush privileges;
重新啟動MySQL,就可以使用新密碼登入了。

乾貨----004----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.