Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

node.js - Connecting to MySQL database through Node after MySQLDUMP

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...