I need to export MySQL database from public server and import it to development one after every content change and I'm trying to automate it with node.js. Is there any out of the box solution to generate .sql file like one created by phpmyadmin but without php or MySQL CLI?
2 Answers
I've used the mysqldump node.js package before
From their documentation:
var mysqlDump = require('mysqldump');
mysqlDump({
host: 'localhost',
user: 'root',
password: '',
database: 'test',
dest:'./data.sql' // destination file
},function(err){
// create data.sql file;
})
This generates the .sql file - it's up to you where to put it / what to do with it however.
1 Comment
Sahil Babbar
Getting the following error:
dest : 'data.sql' // destination file ^^^^ SyntaxError: Unexpected identifier