0

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 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Getting the following error: dest : 'data.sql' // destination file ^^^^ SyntaxError: Unexpected identifier
0

I wouldn't recoment mysqldump because it produces too big a file. My phpMyadmin file was 5MB while mysqldump gave me 15MB. My DB size was small but for big data this could be a problem.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.