后端版本服务器部署成功
This commit is contained in:
@@ -1,21 +1,17 @@
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
// 引入database.js配置
|
||||
const dbConfig = require('../src/config/database').pool.config;
|
||||
|
||||
async function testDevConnection() {
|
||||
console.log('🧪 测试开发环境数据库连接...');
|
||||
|
||||
const dbConfig = {
|
||||
host: '192.168.0.240',
|
||||
port: 3306,
|
||||
user: 'root',
|
||||
password: 'aiotAiot123!',
|
||||
database: 'jiebandata',
|
||||
connectTimeout: 10000
|
||||
};
|
||||
// 使用从database.js导入的配置
|
||||
const config = dbConfig;
|
||||
|
||||
try {
|
||||
console.log('🔗 尝试连接到开发服务器:', dbConfig.host + ':' + dbConfig.port);
|
||||
console.log('🔗 尝试连接到开发服务器:', config.host + ':' + config.port);
|
||||
|
||||
const connection = await mysql.createConnection(dbConfig);
|
||||
const connection = await mysql.createConnection(config);
|
||||
console.log('✅ 开发环境连接成功!');
|
||||
|
||||
// 测试基本查询
|
||||
@@ -24,10 +20,10 @@ async function testDevConnection() {
|
||||
|
||||
// 检查表结构
|
||||
const [tables] = await connection.execute(`
|
||||
SELECT TABLE_NAME
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = 'jiebandata'
|
||||
`);
|
||||
SELECT TABLE_NAME
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = ?
|
||||
`, [config.database]);
|
||||
|
||||
console.log('📊 数据库中的表:', tables.map(t => t.TABLE_NAME).join(', ') || '暂无表');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user