linux下忘記mysql root密碼解決辦法

來源:互聯網
上載者:User

標籤:

vi /etc/my.cnf    #編輯檔案,找到[mysqld],在下面添加一行skip-grant-tables

[mysqld]

skip-grant-tables

:wq!  #儲存退出

service mysqld restart  #重啟MySQL服務

2、進入MySQL控制台

mysql -uroot -p   #直接按斷行符號,這時不需要輸入root密碼。

3、修改root密碼

系統營運  www.osyunwei.com  溫馨提醒:qihang01原創內容©著作權,轉載請註明出處及原文連結

update mysql.user set password=password(‘123456‘) where User="root" and Host="localhost";

flush privileges;  #重新整理系統授權表

grant all on *.* to ‘root‘@‘localhost‘ identified by ‘123456‘ with grant option;

4、取消/etc/my.cnf中的skip-grant-tables

vi /etc/my.cnf   編輯檔案,找到[mysqld],刪除skip-grant-tables這一行

:wq!  #儲存退出

5、重啟mysql

service mysqld restart    #重啟mysql,這個時候mysql的root密碼已經修改為123456

6、進入mysql控制台

mysql -uroot -p  #進入mysql控制台

123456 #輸入密碼

 

詳情:http://www.osyunwei.com/archives/2014.html或者http://www.jb51.net/article/39454.htm

linux下忘記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.