mysql忘記密碼怎麼辦?

來源:互聯網
上載者:User

標籤:os   使用   sp   on   bs   ad   amp   linux   as   

Windows:
1.用系統管理員登陸系統。
2.停止MySQL的服務。
3.進入命令視窗,然後進入MySQL的安裝目錄,比如我的安裝目錄是c:mysql,進入C:mysqlbin
4.跳過許可權檢查啟動MySQL,
c:mysqlbin>mysqld-nt –skip-grant-tables
5.重新開啟一個視窗,進入c:mysqlbin目錄,設定root的新密碼
c:mysqlbin>mysqladmin -u root flush-privileges password "newpassword"
c:mysqlbin>mysqladmin -u root -p shutdown
將newpassword替換為你要用的root的密碼,第二個命令會提示你輸入新密碼,重複第一個命令輸入的密碼。
6.停止MySQL Server,用正常模式啟動Mysql
7.你可以用新的密碼連結到Mysql了。

 

Unix&Linux:
1.用root或者運行mysqld的使用者登入系統;
2.利用kill命令結束掉mysqld的進程;
3.使用–skip-grant-tables參數啟動MySQL Server
shell>mysqld_safe –skip-grant-tables &
4.為[email protected]設定新密碼
shell>mysqladmin -u root flush-privileges password "newpassword"5.重啟MySQL Server

GRANT ALL PRIVILEGES ON *.* TO [email protected]% IDENTIFIED BY ‘123′

linux下的解決方案:
關閉mysql
然後,safe_mysqld –skip-grant-tables
啟動mysql。

mysql -u root
mysql> use mysql
mysql> UPDATE user SET Password=PASSWORD(’xxx’) WHERE user=’root’;
mysql> FLUSH PRIVILEGES;

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.