From 41668d81d5daed86ef92e4cf92b08da2634df1d8 Mon Sep 17 00:00:00 2001 From: Andreas Glimbrant Date: Wed, 23 Jul 2014 12:09:29 +0200 Subject: [PATCH 1/3] mysqldump for local use added, as mysql will generate a warning if you pass -uusername and -ppassword. Should be stored in .my.cnf according to MySQL --- tasks/deployments.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tasks/deployments.js b/tasks/deployments.js index 38b2ceb..0abe7bf 100644 --- a/tasks/deployments.js +++ b/tasks/deployments.js @@ -191,11 +191,15 @@ module.exports = function(grunt) { } }); - // 3) Test whether MYSQL DB is local or whether requires remote access via SSH if (typeof config.ssh_host === "undefined") { // it's a local connection grunt.log.writeln("Creating DUMP of local database"); - cmd = tpl_mysqldump; + // Run mysqldump without user, pass and host as this info should be saved within ~/.my.cnf + cmd = grunt.template.process(tpls.mysqldumplocal, { + data: { + database: config.database + } + }); } else { // it's a remote connection var tpl_ssh = grunt.template.process(tpls.ssh, { @@ -251,6 +255,8 @@ module.exports = function(grunt) { mysqldump: "mysqldump -h <%= host %> -u<%= user %> -p<%= pass %> <%= database %>", + mysqldumplocal: "mysqldump <%= database %>", + mysql: "mysql -h <%= host %> -u <%= user %> -p<%= pass %> <%= database %>", ssh: "ssh <%= host %>", From 85aed20d06a986301ca9de853961e84a00175db5 Mon Sep 17 00:00:00 2001 From: Andreas Glimbrant Date: Wed, 23 Jul 2014 14:58:01 +0200 Subject: [PATCH 2/3] User and pass credentials should be saved in .my.cnf, it will automaticly create a database when running db_push so you dont have to create it manually --- tasks/deployments.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/deployments.js b/tasks/deployments.js index 0abe7bf..49a19dd 100644 --- a/tasks/deployments.js +++ b/tasks/deployments.js @@ -253,11 +253,11 @@ module.exports = function(grunt) { search_replace: "sed -i '' 's#<%= search %>#<%= replace %>#g' <%= path %>", - mysqldump: "mysqldump -h <%= host %> -u<%= user %> -p<%= pass %> <%= database %>", + mysqldump: "mysqldump --databases <%= database %>", - mysqldumplocal: "mysqldump <%= database %>", + mysqldumplocal: "mysqldump --databases <%= database %>", - mysql: "mysql -h <%= host %> -u <%= user %> -p<%= pass %> <%= database %>", + mysql: "mysql -h <%= host %> -u <%= user %> -p<%= pass %>", ssh: "ssh <%= host %>", }; From d3968e151a5ea8f8092d9e45b47079d2b1d01dc4 Mon Sep 17 00:00:00 2001 From: Andreas Glimbrant Date: Wed, 23 Jul 2014 15:00:07 +0200 Subject: [PATCH 3/3] Removed action mysqldump local, and now the credentials should be created through .my.cnf --- tasks/deployments.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tasks/deployments.js b/tasks/deployments.js index 49a19dd..98e5cd2 100644 --- a/tasks/deployments.js +++ b/tasks/deployments.js @@ -195,11 +195,7 @@ module.exports = function(grunt) { if (typeof config.ssh_host === "undefined") { // it's a local connection grunt.log.writeln("Creating DUMP of local database"); // Run mysqldump without user, pass and host as this info should be saved within ~/.my.cnf - cmd = grunt.template.process(tpls.mysqldumplocal, { - data: { - database: config.database - } - }); + cmd = tpl_mysqldump; } else { // it's a remote connection var tpl_ssh = grunt.template.process(tpls.ssh, { @@ -255,8 +251,6 @@ module.exports = function(grunt) { mysqldump: "mysqldump --databases <%= database %>", - mysqldumplocal: "mysqldump --databases <%= database %>", - mysql: "mysql -h <%= host %> -u <%= user %> -p<%= pass %>", ssh: "ssh <%= host %>",