Using MySQLDump When Your Password Has an Ampersand
–
Apparently Bash doesn’t like ampersands (&) within your commands. So when I tried to run Mysqldump with my new password with an ampersand I got this dumb error:
mysqldump -uusername -ppass&word --host=elite.db --add-drop-database --add-drop-table --hex-blob --all-databases
-bash: word: command not found
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
Anyway, the trick (as I graciously learned here) is to use the longer --password option and to enclose the password in escaped quotes as so:
mysqldump -uusername --password=\"pass&word\" --host=elite.db --add-drop-database --add-drop-table --hex-blob --all-databases