방명록
- [Node.js][Trouble Shooting] sqlMessage: "Access denied for user 'root'@'localhost' (using password: NO)"2022년 10월 08일 11시 46분 01초에 업로드 된 글입니다.작성자: DandyNow728x90반응형
const pool = mysql.createPool({ host: process.env.MYSQL_HOST, port: process.env.MYSQL_PORT, user: process.env.MYSQL_USERNAME, password: process.env.MYSQL_PASSWORD, database: process.env.MYSQL_DB, connectionLimit: process.env.MYSQL_LIMIT, });
위는 mysql용 pool 작성 코드이다. 서버를 가동후 Postman에서 쿼리를 날리면 계속 아래와 같은 에러가 발생하였다. 문제의 원인은 황당하게도 오타였다. MYSQL_PASSWORD를 MYSQL_PASSWORLD로 작성했던 것.
PS C:\Users\J\Documents\GitHub\Node-Practice> npm run prod > node-practice@1.0.0 prod > cross-env NODE_ENV=prod node 11_app_mysql.js 서버가 포트 3000번으로 시작되었습니다. Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: NO) at Handshake.Sequence._packetToError (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14) at Handshake.ErrorPacket (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\sequences\Handshake.js:123:18) at Protocol._parsePacket (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\Protocol.js:291:23) at Parser._parsePacket (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\Parser.js:433:10) at Parser.write (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\Parser.js:43:10) at Protocol.write (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\Protocol.js:38:16) at Socket.<anonymous> (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\Connection.js:88:28) at Socket.<anonymous> (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\Connection.js:526:10) at Socket.emit (node:events:390:28) at addChunk (node:internal/streams/readable:315:12) -------------------- at Protocol._enqueue (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\Protocol.js:144:48) at Protocol.handshake (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\protocol\Protocol.js:51:23) at PoolConnection.connect (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\Connection.js:116:18) at Pool.getConnection (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\Pool.js:48:16) at Pool.query (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\mysql\lib\Pool.js:202:8) at C:\Users\J\Documents\GitHub\Node-Practice\mysql\index.js:25:10 at new Promise (<anonymous>) at Object.query (C:\Users\J\Documents\GitHub\Node-Practice\mysql\index.js:24:10) at C:\Users\J\Documents\GitHub\Node-Practice\11_app_mysql.js:22:36 at Layer.handle [as handle_request] (C:\Users\J\Documents\GitHub\Node-Practice\node_modules\express\lib\router\layer.js:95:5) { code: 'ER_ACCESS_DENIED_ERROR', errno: 1045, sqlMessage: "Access denied for user 'root'@'localhost' (using password: NO)", sqlState: '28000', fatal: true } node:internal/process/promises:246 triggerUncaughtException(err, true /* fromPromise */); ^ [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".] { code: 'ERR_UNHANDLED_REJECTION' }
728x90반응형'언어·프레임워크 > Node.js' 카테고리의 다른 글
[Node.js] API 서버에 api-key 적용 및 Swagger 문서화 (0) 2024.01.25 [Node.js] Swagger을 이용한 API 문서 생성 (0) 2024.01.24 [Node.js] [문제해결] Vue.js에서 마이크로소프트 액세스 mdb 파일을 읽어 오려다가... SyntaxError (0) 2022.05.25 [Node.js][유튜브 강의 노트] 개발자의품격_Node.js에서 API 서버 만들기 (0) 2021.11.28 [Node.js][유튜브 강의 노트] 개발자의품격_한시간만에 끝내는 Node.js 입문 #2 (0) 2021.11.22 다음글이 없습니다.이전글이 없습니다.댓글