新安裝的MySQL5.7,登錄時提示密碼錯誤,安裝的時候并沒有更改密碼,后來通過免密碼登錄的方式更改密碼,輸入update mysql.user set password=password(‘root’) where user=’root’時提示ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’,原來是mysql數(shù)據(jù)庫下已經(jīng)沒有password這個字段了,password字段改成了authentication_string
所以更改語句替換為update mysql.user set authentication_string=password(‘root’) where user=’root’ ;即可
我的系統(tǒng)版本如下:
完整的更改MySQL密碼的方式如下:
1、vim /etc/my.cnf 加入skip-grant-tables
2、重啟MySQL, /etc/init.d/mysqld restart
3、終端輸入 mysql 直接登錄MySQL數(shù)據(jù)庫,然后use mysql
4、update mysql.user set authentication_string=password(‘root’) where user=’root’ ;
mysql5.7更改密碼應該采用命令 ALTER USER ‘root’@’localhost’IDENTIFIED BY ‘********’其中密碼的命名規(guī)則有所改變。
MySQL 設(shè)置的密碼中必須至少包含一個大寫字母、一個小寫字母、一個特殊符號、一個數(shù)字,
密碼長度至少為8個字符
5、編輯my.cnf文件刪掉skip-grant-tables 這一行,然后重啟MySQL,/etc/init.d/mysqld restart,否則MySQL仍能免密碼登錄
6、mysql -u root -p
然后輸入密碼即可登錄MySQL數(shù)據(jù)庫
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://blog.csdn.net/u010603691/article/details/50379282