我正在尝试将mysql与node.js连接起来,但是当我执行undefined
时得到了console.log(result)
。这是我的代码:
dbConnection.js
const mysql = require('mysql');
module.exports = () => {
return mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'root',
database: 'news_portal'
});
}
news.js
const dbConnection = require('../../config/dbConnection');
module.exports = app => {
const connection = dbConnection();
app.get('/', (req, res) => {
connection.query('SELECT * FROM news', (err, result) => {
console.log(result);
});
});
}
数据库具有信息,并且用户名和密码正确。有人能帮我吗?谢谢。
答案 0 :(得分:0)
我终于解决了。 <p-calendar appendTo="body" [style]="{'width':'95%'}" [inputStyle]="{'width':'95%'}"
</p-calendar>
个var包含.slider:first-of-type {
height: 100vh;
width: 100vw;
overflow-x: hidden;
}
。我在this post
基本上我所做的是:
err
Client does not support authentication protocol requested by server; consider upgrading MySQL client
感谢您的帮助。