60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
const mysql = require('mysql2');
|
||
|
||
// 数据库连接配置
|
||
const dbConfig = {
|
||
host: '129.211.213.226',
|
||
port: 9527,
|
||
user: 'root',
|
||
password: 'aiotAiot123!',
|
||
database: 'jiebandata'
|
||
};
|
||
|
||
// 创建连接
|
||
const connection = mysql.createConnection(dbConfig);
|
||
|
||
// 连接数据库
|
||
connection.connect((err) => {
|
||
if (err) {
|
||
console.error('数据库连接失败: ' + err.stack);
|
||
return;
|
||
}
|
||
console.log('数据库连接成功,连接ID: ' + connection.threadId);
|
||
|
||
// 检查animals表结构
|
||
connection.query('DESCRIBE animals', (error, results) => {
|
||
if (error) {
|
||
console.error('查询animals表结构失败: ' + error.stack);
|
||
connection.end();
|
||
return;
|
||
}
|
||
|
||
console.log('\n=== animals表结构 ===');
|
||
console.table(results);
|
||
|
||
// 检查merchants表结构
|
||
connection.query('DESCRIBE merchants', (error, results) => {
|
||
if (error) {
|
||
console.error('查询merchants表结构失败: ' + error.stack);
|
||
connection.end();
|
||
return;
|
||
}
|
||
|
||
console.log('\n=== merchants表结构 ===');
|
||
console.table(results);
|
||
|
||
// 检查users表结构
|
||
connection.query('DESCRIBE users', (error, results) => {
|
||
if (error) {
|
||
console.error('查询users表结构失败: ' + error.stack);
|
||
connection.end();
|
||
return;
|
||
}
|
||
|
||
console.log('\n=== users表结构 ===');
|
||
console.table(results);
|
||
|
||
connection.end();
|
||
});
|
||
});
|
||
});
|
||
}); |