數據庫登錄失敗 ERROR 1045 (28000)

從新搭建開發環境,修改MySQL密碼後登錄時出現標題所述錯誤。
Server version: 5.7.29 MySQL Community Server (GPL)
後發現使用初始密碼登錄成功,故懷疑修改密碼時存在問題。
未成功修改密碼的代碼爲:
set password for root@localhost=password('xxxxxx');
嘗試使用另外一種方式:
UPDATE mysql.user SET authentication\_string=PASSWORD('yourPassword') where User='root';
出現錯誤:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
根據錯誤提示設置密碼:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourPassword';
成功,刷新權限表並退出:
FLUSH PRIVILEGES;
exit;
相關文章
相關標籤/搜索