programing

MariaDB 풀이 연결을 생성하지 못했습니다.

itmemos 2023. 10. 4. 20:59
반응형

MariaDB 풀이 연결을 생성하지 못했습니다.

노드 프로젝트를 2-3분간 실행한 후 1분 정도마다 나타나는 경고/오류 메시지에 직면해 있습니다.온라인으로 검색해 보았지만 이에 대한 해결책을 찾을 수 없었습니다.

pool failed to create connection ((conn=-1, no: 45009, SQLState: 08S01) socket has unexpectedly been closed)

my db.js

const mysql = require("mysql"); //^2.18.1
const mariadb = require("mariadb"); //^2.5.3

const DB_OPTIONS = {
   host: "127.0.0.1",
   user: "root",
   password: "",
   database: "test-db",
   port: 3306,
   minDelayValidation: 5000
};

const connection = mariadb.createPool(DB_OPTIONS);

connection.getConnection().then((conn) => {
   console.log("Connected to DB!", conn.threadId);
   if (conn) conn.release();
}).catch((err) => {
   console.error("Error while connecting to DB", err);
});

module.exports = connection;

test.js

...
let database = require("./../middleware/db");
...
...
try 
{
   database.query(dbQuery, dbParameters).then((result) => {
      ...
   }).catch((dbCatchErr) => {
      ...
   })
}
catch (catchErr)
{
   console.error(catchErr);
}

MariaDB 버전: 10.3.23

언급URL : https://stackoverflow.com/questions/66777706/mariadb-pool-failed-to-create-connection

반응형