初次登錄MySQL修改密碼是出現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字段改爲了mysql

authentication_stringsql

因此更改語句替換爲update MySQL.user set authentication_string=password('root') where user='root' ;便可數據庫

完整的更改MySQL密碼的方式以下:vim

一、vim /etc/my.cnf 加入skip-grant-tables.net

二、重啓MySQL, /etc/init.d/mysqld restartrest

三、終端輸入 mysql 直接登陸MySQL數據庫,而後use mysqlip

四、update mysql.user set authentication_string=password('root') where user='root' ;get

mysql5.7更改密碼應該採用命令ALTER USER 'root'@'localhost'IDENTIFIED BY '********'其中密碼的命名規則有所改變,詳見string

五、編輯my.cnf文件刪掉skip-grant-tables 這一行,而後重啓MySQL,/etc/init.d/mysqld restart,不然MySQL仍能免密碼登陸it

六、mysql -u root - 而後輸入密碼便可登陸MySQL數據庫

相關文章
相關標籤/搜索