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
'********'其中密碼的命名規則有所改變,
5、編輯my.cnf文件刪掉skip-grant-tables 這一行,然後重啓MySQL,/etc/init.d/mysqld restart,否則MySQL仍能免密碼登錄
6、mysql -u root -p
然後輸入密碼即可登錄MySQL數據庫