반응형

Mysql을 통해 환경을 세팅하는 중 가장 흔하게 만날 수 있는 오류가 하나 있다.

 

아래와 같은 오류인데, 이 오류가 무엇인지! 해결방법은 무엇인지 알아보자.

 

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

오류의 원인

Mtysql 8부터는 Pluggable Authentication methods를 지원한다. 기본적으로 Caching_sha2_password가 사용이 되고,

우리가 흔히 사용하는 user/password 방법인 mysql_native_password를 사용하는 방법은 default가 아니다.

당연히 SHA2와 같은 암호화 알고리즘을 쓰는 방법은 단순히 Password를 사용하는 방법보다 안전하다.

하지만 Mysqljs에서는 mysql_native_password만 지원을 하기 때문에 위와 같은 문제가 발생한다.

mysqljs를 꼭!! 반드시!! 사용해야한다면 아래 1번 해결방법을 따라하면 된다.

 

반응형

해결방법

해결방법1

특정 사용자에 대해서 mysql_native_password 접근을 허용하면 된다.

아래 SQL문으로 접근을 허용 할 수 있다.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password '비밀번호'

매우 간단하고 효과적인 방법이다. 그리고 Mysqljs에 의존적인 라이브러리를 사용하고 있는 경우 어쩔 수 없이 선택해야 하는 방법이기도 하다. 하지만 이 방법을 사용할때 한가지는 알고있으면 좋을 것 같다.

"더 Secure한 방법이 있지만, 나는 지금 그 이점을 버리고 내가 편한 방법으로 진행중이다"

 

해결방법2

오래된 Mysqljs를 버리고 다른 Library로 교체

https://www.npmjs.com/package/mysql2

 

mysql2

fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS. Latest version: 2.3.3, last published: a year ago. Start using mysql2 in your project by running `npm i mysql2`. There are 3243 other projects in the npm re

www.npmjs.com

https://dev.mysql.com/doc/dev/connector-nodejs/8.0/

 

MySQL Connector/Node.js X DevAPI Reference Index

MySQL Connector/Node.js MySQL Connector/Node.js is a MySQL 8 driver for Node.js, officially supported and maintained by Oracle. It contains a pure JavaScript implementation of the X DevAPI, an Application Programming Interface for working with the MySQL Do

dev.mysql.com

 

mysql2의 경우 mysql js를 fork하여 발전시킨 오픈소스 라이브러리이고,

connector-nodejs는 Oracle에서 개발, 유지중인 nodejs mysql driver이다.

 

 

반응형

+ Recent posts