Bash script and escaping special characters in password

Use double quotes twice, escaped and not escaped: -p"\"$MYPASSWORD\""

#!/bin/sh
source pass.cre
/usr/bin/ssh -p 91899 user@remoteHost 'mysqldump -u db_user -p"\"$MYPASSWORD\"" my_database |  gzip -c >  my_database.sql.gz'

Or an other version

/usr/bin/ssh -p 91899 user@remoteHost "mysqldump -u db_user -p\"'io#bc@14@9$#jf7AZlk99'\" my_database | gzip -c > my_database.sql.gz"

Examples

% source pass.cre
% ssh user@host mysqldump -u root -p$MYPASSWORD    
user@host's password: 
zsh:1: bad pattern: -p#8111*@uu(

% source pass.cre
% ssh user@host mysqldump -u root -p"$MYPASSWORD"   
user@host's password: 
zsh:1: bad pattern: -p#8111*@uu(

% source pass.cre
% ssh user@host mysqldump -u root -p"\"$MYPASSWORD\""
user@host's password: 
Warning: Using a password on the command line interface can be insecure.

The problem is that your string is being interpreted twice, once by the local shell, and again by the remote shell which ssh is running for you. So you need to quote twice, using either of these:

-p\''#8111*@uu('\'
-p"'#8111*@uu('"

Edit: If you are going to double-quote "" the entire command, you will have problems with passwords containing $. You need to single-quote the command to avoid this. But you still need to single quote the -p value as it is interpreted twice. So you need single quotes inside single quotes.

This is done by use a single quoted quote (\') as in this example:

'I don'\''t like java'

will give you the string I don't like java. So your double-quoted example becomes the single-quoted:

/usr/bin/ssh -p 91899 user@remoteHost 'mysqldump -u db_user -p'\''io#bc@14@9$#jf7AZlk99'\''my_database | gzip -c > my_database.sql.gz'

Don't you just love it?