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.

This commit is contained in:
Andrew Smith 2011-06-27 17:00:33 +10:00
parent 898874d33c
commit a1d1f9a26c

View File

@ -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'`"