Sign up ×  I am running a mysqldump via a bash script and have
encountered a problem with a password that contains special
characters.  mysqldump -hlocalhost -uUSERNAME -pPA$$W0RD
DATABASE |                                  gzip >
/home/USERNAME/backups-mysql/BACKUP.gz  How do I escape the
password?  share|improve this question  2 Answers 2  up vote 5
down vote accepted  Even better, don't put the username or
password on the command line where it can be seen by anyone who
can do ps -ef.  Create a control file named something like
/etc/mysqldump.cnf:   ...where client is literal (not the name
of your server) and YOUR_MYSQL_ROOT_PASSWORD is... well... your
mysql root password.  Then invoke like this:  mysqldump
--defaults-file=/etc/mysqldump.cnf DATABASE |
gzip > /home/USERNAME/backups-mysql/BACKUP.gz  Personally my
invocation is more like this:  NOW=`perl -e 'print time;'` cd
/opt/backup/mysql mkdir $NOW for i in `echo "show databases" |
mysql -u root --password="MySqlRootPasswo