hello using gruntfile create dump of sql file , want execute same file in server.
code create dump working fine , unable execute dump. please me.. stuck on yesterday.
var grunt=require('grunt'); module.exports = function(grunt) { console.log("grunt called"); grunt.initconfig({ // load database config external json (optional) //db_config: grunt.file.readjson('config/db.json'), db_dump: { options: { // common options should defined here }, // "local" target "local": { "options": { "title": "local db", "database": "test", "user": "user", "pass": "pass", "host": "host1", "backup_to": "local.sql" } } }, mysqlrunfile: { options: { connection: { "database": "test", "user": "user", "pass": "pass", "host": "host2", multiplestatements: true }, yourtarget1: { src: ['/local.sql'] } } } }); require('load-grunt-tasks')(grunt); };
this similar script run node rebuild-db. spawns child process run mysql script , prints out errors occur. you'll have fill in own variables.
var exec = require('child_process').exec, child, var fs = require('fs'); var rebuild_file = __dirname + '/defaultdata.sql'; var runsqlscript = function(file, callback) { rebuild_db = 'mysql -u ' + nconf.get('databaseuser') + ' -h ' + nconf.get('databasehost') + ' -p' + nconf.get('databasepass') + ' ' + nconf.get('databasename') + ' < ' + file; child = exec(rebuild_db, function(error, stdout, stderr) { if (error !== null) { console.log('rebuild error: ' + error); console.log('stdout: ' + stdout); console.log('stderr: ' + stderr); process.exit(1); return; } console.log('successfully rebuild database using: '); console.log(' ' + file); callback(); }); }; var rebuild = function() { runsqlscript(rebuild_file, function() { process.exit(0); }); }; rebuild();
Comments
Post a Comment