MySQL 5.7 忘記密碼後修改密碼

來源:互聯網
上載者:User

標籤:alter   使用者   new   HERE   設定   oba   設定檔   The   配置   

1、修改登入設定

 vim /etc/my.cnf #或/etc/mysql/my.cnf  [mysqld] skip-grant-tables  #新加

2、重啟mysql服務

3、直接mysql登入,並修改密碼

update mysql.user set authentication_string=password('新密碼') where User='root'; #5.7中儲存密碼欄位是這個,desc先看下儲存密碼欄位。其他版本一般如下修改#mysql> UPDATE mysql.user SET Password = password ('new-password') WHERE User = 'root' ; #如遇到報錯 You must reset your password using ALTER USER statement before executing this statement. 原因是密碼有效期間已到,需要執行 1.  ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; #設定密碼永不到期,改回預設方法 alter user 'root'@'localhost' password expire default 2.  或者 set global default_password_lifetime=0 或直接寫在設定檔裡面,到期時間為0表示永不到期,全域生效。推薦上中方法僅特定使用者密碼不到期flush privileges; #使用update修改密碼必須要執行此步或者set password=passwprd('新密碼');#不須重新整理授權表,完整格式 SET PASSWORD FOR 'root'@'localhost'=PASSWORD('newpassword');

4、修改設定檔

刪除

skip-grant-tables

重啟服務

MySQL 5.7 忘記密碼後修改密碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.