MySQL忘記root使用者密碼修改方法

來源:互聯網
上載者:User

標籤:

 

 

一般來說在MySQL修改使用者密碼有好幾種方法:

1.修改自己的密碼可用:

set password=password(‘123456‘);

 

2.修改其它使用者的密碼可用:

set password for ‘username‘@‘host‘=password(‘123456‘);

 

3.通過修改mysql庫中的user表中的password欄位,可用:

update mysql.user set password=password(‘123456‘) where User=‘username‘ and Host=‘192.168.1.172‘;

 

4.用mysqladmin命令:

mysqladmin -uusername -p1234 password "123456" (其中1234是舊密碼,123456是新密碼)

 

以上幾種命令方式都是在使用者登陸時和具有相應的許可權才能修改,如root使用者,那如果root使用者的密碼也忘記了怎麼辦,可用如下方式修改:

1.關閉資料庫:service mysql stop;2.使用mysqld_safe --skip-grant-tables &啟動資料庫3.使用空密碼進入資料庫:mysql命令後直接斷行符號。4.使用update語句修改root密碼。5.關閉資料庫並重新以正常方式啟動資料service mysql stop;service mysql start;

 

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.