MySQL5.7更改密碼時出現ERROR 1054 (42S22)的解決方法
新安裝的MySQL5.7,登入時提示密碼錯誤,安裝的時候並沒有更改密碼,後來通過免密碼登入的方式更改密碼,輸入update mysql.user set password=password('root') where user='root'時提示ERROR 1054 (42S22): Unknown column 'password' in 'field list',原來是mysql資料庫下已經沒有password這個欄位了,password欄位改成了authentication_string
所以更改語句替換為update mysql.user set authentication_string=password('root') where user='root' ;即可
我的系統版本如下:
完整的更改MySQL密碼的方式如下:
1、vim /etc/my.cnf 加入skip-grant-tables
2、重啟MySQL, /etc/init.d/mysqld restart
3、終端輸入 mysql 直接登入MySQL資料庫,然後use mysql
4、update mysql.user set authentication_string=password('root') where user='root' ;
mysql5.7更改密碼應該採用命令 ALTER USER'root'@'localhost'IDENTIFIED BY'********'其中密碼的命名規則有所改變。
MySQL 設定的密碼中必須至少包含一個大寫字母、一個小寫字母、一個特殊符號、一個數字,
密碼長度至少為8個字元
5、編輯my.cnf檔案刪掉skip-grant-tables 這一行,然後重啟MySQL,/etc/init.d/mysqld restart,否則MySQL仍能免密碼登入
6、mysql -u root -p
然後輸入密碼即可登入MySQL資料庫
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援我們。