MySQL5.7更改密碼時出現ERROR 1054 (42S22): Unknown column 'password' in 'field list'
阿新 • • 發佈:2019-01-01
新安裝的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
'********'其中密碼的命名規則有所改變,詳見
http://blog.csdn.net/u010603691/article/details/50541979
5、編輯my.cnf檔案刪掉skip-grant-tables 這一行,然後重啟MySQL,/etc/init.d/mysqld restart,否則MySQL仍能免密碼登入
6、mysql -u root -p
然後輸入密碼即可登入MySQL資料庫