1. 程式人生 > >MySQL5.7更改密碼時出現ERROR 1054 (42S22): Unknown column 'password'

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

新安裝的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,自己新建一個檔案my.ini,然後將裡面的內容進行修改:

首先在下面的檔案中新增紅色框中的內容,然後需要額外新增一句:skip-grant-tables


2.重啟mysql服務:net stop mysql 然後net start mysql

3.此時使用終端輸入mysql可以 直接登入進入mysql資料庫,然後使用命令use mysql

4.執行命令:

update mysql.user set authentication_string=password('anywhere') where user='root' ;
5.此時從my.ini檔案刪除掉skip-grant-tables 這一行,然後重啟Mysql.

6.此時可以使用mysql -u root -p使用剛才的密碼登入即可了。