node.js
와 MariaDB
를 연결 할 때 오류가 나서 답답합니다. cloudtype
이라는 클라우드에 올려두고 실행하고 있는데요. 자꾸 UNSUPPORTED_AUTH_METHOD
와 AUTH_SWITCH_PLUGIN_ERROR
가 뜨네요... 모듈을 mysql2
로 바꾸기, ALTER USER
입력하기 등등 여러가지를 이것저것 해봤는데도 안 되어서 참 답답합니다.
한가지 신기한 사실은 express
의 app.get
내에서 실행할 때는 된다는 점입니다. 예를 들어 코드가 아래와 같다고 하면
//1번 코드
app.get('/', (req, res) => {
res.header("Access-Control-Allow-Origin", "*")
DBFunction('arg')
.then(result => {
console.log(result)
res.send(result);
})
})
//2번 코드
function myFunction() {
DBFunction('arg')
.then(result => {
console.log(result)
return;
})
}
myFunction()
1번 코드는 되는데 2번 코드는 안 된다는 점입니다... 무엇이 문제인지 전혀 모르겠습니다. 알려주시면 감사하겠습니다 😭
이것 저것 다 해봐서 확실친 않은데 우선 참고한 자료는 다음과 같습니다.
https://islibrary.tistory.com/49
https://neos518.tistory.com/86
https://stackoverflow.com/questions/66591333/change-mysql-authentication-plugin-to-caching-sha2-password
무엇이 문제일까요 도대체ㅠㅠ
불러오는 중...