nodejs使用express連接MySQL數據庫

剛搭建了本地的MySQL數據庫,用nodejs連接的時候報錯:

錯誤:Client does not support authentication protocol requested by server; consider upgrading MySQL client

(客戶端不支持服務器請求的身份驗證協議;請考慮升級MySQL客戶端)

查找了一些網上的資料文檔發現是新版本MySQL的版本加密方式不同,參考資料解決,用命令行連接數據庫:

mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密碼';

原因:MySQL8.0.4開始,這樣默認是不行的。因爲之前,MySQL的密碼認證插件是“mysql_native_password”,而現在使用的是“caching_sha2_password”

參考資料:

https://blog.csdn.net/ad996454914/article/details/80904771

https://blog.csdn.net/qq_19707521/article/details/80226321

https://blog.csdn.net/XDMFC/article/details/80263215

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章