MySQL5.7更改密碼時出現ERROR 1054 (42S22): Unknown column 'password' in 'field list'

新安裝的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

所以更改語句替換爲updateMySQL.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數據庫




發佈了76 篇原創文章 · 獲贊 51 · 訪問量 71萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章