This commit is contained in:
董海洋
2026-05-24 19:33:45 +08:00
parent ab0b7b4644
commit f2a9fec405
4 changed files with 281 additions and 27 deletions
+34
View File
@@ -0,0 +1,34 @@
const mysql = require('mysql2/promise');
const config = {
host: '110.42.255.239',
port: 3306,
user: 'admin',
password: 'Admin@123',
database: 'miniprogram'
};
async function testConnection() {
try {
console.log('尝试连接到:', config.host, config.port);
const connection = await mysql.createConnection(config);
console.log('✅ 数据库连接成功\n');
// 检查所有商品的图片URL
const [goods] = await connection.execute('SELECT id, name, images FROM goods LIMIT 10');
console.log(`找到 ${goods.length} 条商品记录\n`);
for (const item of goods) {
console.log(`商品ID ${item.id}: ${item.name}`);
console.log(` 图片: ${item.images}`);
}
await connection.end();
console.log('\n✅ 检查完成');
} catch (error) {
console.error('❌ 连接失败:', error.message);
process.exit(1);
}
}
testConnection();