From a1d1f9a26cd00a9dd760dbe9737343e96954b998 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Mon, 27 Jun 2011 17:00:33 +1000 Subject: [PATCH] It's possible to have a user without a password, if this happens then even passing an empty password to the command line gives an error, so instead, only append the password to the OPTs var if it's set. --- automysqlbackup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/automysqlbackup.sh b/automysqlbackup.sh index 7be5ed3..bf3f9fb 100755 --- a/automysqlbackup.sh +++ b/automysqlbackup.sh @@ -320,7 +320,7 @@ if [ "${MAX_ALLOWED_PACKET}" ]; # Database dump function dbdump () { -${MYSQLDUMP} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} ${OPT} ${1} > ${2} +${MYSQLDUMP} --user=${USERNAME} --host=${DBHOST} ${OPT} ${1} > ${2} return $? } @@ -380,6 +380,10 @@ else HOST=${DBHOST} fi +if [ ! -z "${PASSWORD}" ]; then + OPT="${OPT} --password=${PASSWORD}" +fi + # If backing up all DBs on the server if [ "${DBNAMES}" = "all" ]; then DBNAMES="`${MYSQL} --user=${USERNAME} --password=${PASSWORD} --host=${DBHOST} --batch --skip-column-names -e "show databases"| ${SED} 's/ /%/g'`"