const mysql = require('mysql2');
const pool = mysql.createPool({
host: 'localhost',
user: 'root',
database: 'node_complete',
password: 'ankur_54'
});
pool.execute('SELECT * FROM products')
.then(result => {
console.log(result);
})
.catch(err => {
console.log(err);
});
这是我的代码,用于从MySQL表获取数据。但是它没有这样做,而是返回了此错误。我尝试使用:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ankur_54';
FLUSH PRIVILEGES;
但是不幸的是,那也不起作用。有人可以帮我吗?