diff --git a/AUTHORS b/AUTHORS
index 92a21841f61d0328b5ba4646ccf9032536bc5b86..8c1d1c8430c6c27102613a72bd210e53a68cde0c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -34,3 +34,4 @@ Olivier Berger <oberger@ouvaton.org> -- much work on the dup handler
 stefan <s.freudenberg@jpberlin.de> -- dup support for Amazon S3 buckets
 maniacmartin <martin@maniacmartin.com> -- rdiff confusing error message fix
 Chris Nolan <chris@cenolan.com> -- maildir subdirectory expansion
+Dan Carley -- mysql bugfix
diff --git a/ChangeLog b/ChangeLog
index 8dec95c5ddaa9d83334d8e56db1e856be0ad9a08..dd8f605969c9926e6c7385c1bef44bdf06d46143 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,8 @@ version 0.9.8 -- UNRELEASED
 	mysql:
 	 . Don't lock tables in the information_schema database
 	   (Closes: #587011)
+	 . Fix code logic to make dbusername/dbpassword actually usable
+	   (Closes Redmine bug #2264)
     doc changes
 	manpage:
 	 . Fix typo in manpage (Closes: #583778)
diff --git a/handlers/mysql.in b/handlers/mysql.in
index 68d51978b2b3bcd8af389240a0b2cfdfad7bd546..0282046f6387c6c458f07fe7a786e28186017d7f 100644
--- a/handlers/mysql.in
+++ b/handlers/mysql.in
@@ -86,7 +86,7 @@ fi
 
 defaultsfile=""
 
-if [ "$dbusername" != "" -a "$dbpassword" != "" ]
+if [ -n "$dbusername" -a -n "$dbpassword" ]
 then
    if [ $usevserver = yes ]
    then
@@ -140,13 +140,10 @@ password="$dbpassword"
 EOF
    umask $oldmask
    defaultsfile="--defaults-extra-file=$mycnf"
-fi
 
-# if a user is not set, use $configfile, otherwise use $mycnf
-if [ "$user" == "" ]; then
-   user=root;
-   defaultsfile="--defaults-extra-file=$configfile"
-else
+# else, if a user is set use her .my.cnf
+elif [ -n "$user" ]
+then
    userset=true;
    if [ $usevserver = yes ]
    then
@@ -169,6 +166,10 @@ else
 	
    defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
    debug "using $defaultsfile"
+# otherwise use $configfile
+else
+   user=root
+   defaultsfile="--defaults-extra-file=$configfile"
 fi
 
 #######################################################################