i've imported a mysql database from old to new machine using mysqldump. on the new machine, i can read the local database and print the database contents to the console, meaning the import worked.
To connect to this database, i'm using Node (eg node myServerFile.js
) but it's not connecting to this database on the new machine. my react/node files are exactly the same on both machines, the difference is a new machine with a freshly installed react/node/mysql environment.
i can't get past the 'Error connecting to database' message
myServerFile.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'xxxx',
password: 'xxxx',
database: 'xxxx'
});
var router = express();
connection.connect(function(err){
if(!err) {
console.log('Database is connected');
}
else {
console.log('Error connecting to database');
}
});
question from:
https://stackoverflow.com/questions/65908651/connecting-to-mysql-database-through-node-after-mysqldump 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…