Node.js

[Node.js] MySQL과 연동 시 발생하는 에러 해결 방법

코드사냥꾼 2020. 6. 7. 15:22

Node.js 와 MySQL를 연동하며 사용하던 도중 갑자기 에러가 발생하며 웹 사이트에 진입되지 않았다.

해당 오류는 노드에서 MySQL version 8.0 의 새로운 인증 방법을 지원하지 않기 때문에 발생한 것으로, 한 줄의 코드를 작성하면 간편하게 해결 가능하다.

MySQL 내 에러메시지

 

💡 해결 방법

 'Client does not support authentication protocol requested by server; consider upgrading MySQL client' 

=> ALTER USER ‘root(본인 계정명)’@localhost’ IDENTIFIED WITH mysql_native_password BY ‘사용할패스워드’

 

 

[참고]

https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server

 

MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

I can't make a simple connection to the server for some reason. I install the newest MySQL Community 8.0 database along with Node.JS with default settings. This is my node.js code var mysql =

stackoverflow.com