const mysql =require('mysql');// 创建MySQL连接const connection = mysql.createConnection({host:'localhost',user:'username',password:'password',database:'news'});// 执行SQL查询
connection.query('SELECT * FROM news ORDER BY time DESC',function(error, results, fields){if(error)throw error;// 在控制台上输出查询结果
console.log(results);// 关闭MySQL连接
connection.end();});