From a1365dd77fab39a5e64b5f86d2027c770e865f9d Mon Sep 17 00:00:00 2001 From: luoyonghuang <2308014474@qq.com> Date: Mon, 7 Oct 2024 22:09:42 +0800 Subject: [PATCH] Update db.js --- db.js | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/db.js b/db.js index d7b62d8..1ef600c 100644 --- a/db.js +++ b/db.js @@ -1,24 +1,24 @@ -const mysql = require('mysql2/promise'); - -// 创建连接池 -const pool = mysql.createPool({ - host: 'localhost', // 数据库地址 - user: 'root', // 数据库用户名 - password: '20041025', // 数据库密码 - database: 'class_k' ,// 使用的数据库 - waitForConnections: true, - connectionLimit: 10, - queueLimit: 0 -}); - -// 测试数据库连接 -pool.getConnection((err, connection) => { - if (err) { - console.error('Error connecting to the database:', err); - } else { - console.log('Database connected successfully!'); - connection.release(); // 释放连接 - } -}); - -module.exports = pool; +const mysql = require('mysql2/promise'); + +// 创建连接池 +const pool = mysql.createPool({ + host: 'localhost', // 数据库地址 + user: 'root', // 数据库用户名 + password: '123456', // 数据库密码 + database: 'class_k' ,// 使用的数据库 + waitForConnections: true, + connectionLimit: 10, + queueLimit: 0 +}); + +// 测试数据库连接 +pool.getConnection((err, connection) => { + if (err) { + console.error('Error connecting to the database:', err); + } else { + console.log('Database connected successfully!'); + connection.release(); // 释放连接 + } +}); + +module.exports = pool;