1. 程式人生 > >MySQL5.7 修改使用者密碼

MySQL5.7 修改使用者密碼

由於需要定期修改資料庫密碼,就著手操作,一開始想當然的寫下了SQL:

update mysql.user set password='newpassword' where user='username';

結果提示沒有password欄位,原來5.7密碼改用authentication_string儲存密碼,然後就修改為:

update mysql.user set authentication_string='newpassword' where user='username';

然而儲存的密碼是明文,仔細一看指令碼,沒有把密碼串轉成密碼格式

最終:

update mysql.user set authentication_string=PASSWORD('newpassword') where user='username';