MySQL5.7已經沒有password這個字段了,改成了authentication_string
update mysql.user set authentication_string=password('root') where user='root' ;
完整的更改MySQL密碼的方式如下:
1.vim /etc/my.cnf [mysqld]段增加skip-grant-tables 2./etc/init.d/mysqld restart 3.終端輸入mysql 直接登錄MySQL數據庫,然后use mysql 4.update mysql.user set authentication_string=password('root') where user='root' ; 5.flush privileges; #立即生效 6.quit; 7.編輯/etc/my.cnf 刪掉skip-grant-tables, 然后重啟MySQL /etc/init.d/mysqld restart 8.mysql -u root -p 然后輸入密碼即可登錄MySQL數據庫
舊版改密碼的命令如下,MySQL5.7 password改成了authentication_string
mysql> update user set password=password(“新密碼”) where user=”用戶名”;
