35 lines
909 B
JavaScript
35 lines
909 B
JavaScript
|
|
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();
|