這是mysql 8.0版本才出現的問題,原因是mysql 8.0 默認使用 caching_sha2_password 身份驗證機制 —— 從原來的 mysql_native_password 更改為 caching_sha2_password。
解決辦法:
可以更換版本但是感覺治標不治本,建議修改身份驗證機制
1、登陸mysql
在mysql的bin目錄下打開cmd(默認是C:\Program Files\MySQL\MySQL Server 8.0\bin)
輸入:mysql -uroot -p 接着輸入密碼
2、登陸mysql成功之后輸入:
alter user 'root'@'localhost' identified by 'root' password expire never;
alter user 'root'@'localhost' identified with mysql_native_password by 'root'
flush privileges;
其中root為mysql密碼
完美解決