更新政府端和银行端
This commit is contained in:
45
government-backend/test-connection.js
Normal file
45
government-backend/test-connection.js
Normal file
@@ -0,0 +1,45 @@
|
||||
require('dotenv').config();
|
||||
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
async function testConnection() {
|
||||
try {
|
||||
// 从环境变量获取数据库配置
|
||||
const config = {
|
||||
host: process.env.DB_HOST || '129.211.213.226',
|
||||
port: process.env.DB_PORT || 9527,
|
||||
user: process.env.DB_USER || 'root',
|
||||
password: process.env.DB_PASSWORD || 'aiotAiot123!',
|
||||
database: process.env.DB_NAME || 'ningxia_zhengfu'
|
||||
};
|
||||
|
||||
console.log('正在连接数据库...');
|
||||
console.log('📋 数据库配置信息:');
|
||||
console.log(` 主机: ${config.host}`);
|
||||
console.log(` 端口: ${config.port}`);
|
||||
console.log(` 数据库名: ${config.database}`);
|
||||
console.log(` 用户名: ${config.user}`);
|
||||
|
||||
// 创建数据库连接
|
||||
const connection = await mysql.createConnection(config);
|
||||
console.log('✅ 政府端后端数据库连接成功');
|
||||
|
||||
// 查询数据库中的表
|
||||
const [tables] = await connection.query(
|
||||
"SELECT table_name FROM information_schema.tables WHERE table_schema = ?",
|
||||
[config.database]
|
||||
);
|
||||
console.log(`📚 数据库表数量: ${tables.length}`);
|
||||
|
||||
// 关闭连接
|
||||
await connection.end();
|
||||
console.log('🔒 数据库连接已关闭');
|
||||
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('❌ 政府端后端数据库连接失败:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
testConnection();
|
||||
Reference in New Issue
Block a user