mysql如何修改密碼,root密碼忘記怎麼辦?

來源:互聯網
上載者:User

標籤:

mysql有三種方式修改root密碼:

1.mysqladmin -uroot -p password "12"

這樣就能將root密碼改為12,注意新密碼用雙引號引起來

2.root登陸mysql伺服器後,用update語句更新mysql資料庫中的user表

update mysql.user set password=password("new_password") where user=‘root‘ and host=‘localhost‘

執行完畢後flush privileges重新重新整理載入語句

3.set password=password("new_password");(普通使用者只能用此方法修改密碼,因為許可權不夠)

 

如果root密碼忘掉或者丟失怎麼辦:

步驟:

1.使用--skip-grant--tables啟動mysql服務:

mysqld_safe --skip-grant-tables

2.登陸root使用者,設定新的密碼

update mysql.user set password=password("new_password") where user=‘root‘ and host=‘localhost‘

flush privileges

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.