delalli delalli - 6 months ago 8
MySQL Question

Query not running. There is # in mysql password

I am running a mysqldump command from mac terminal. There is # in the password. Getting

-bash: !3: event not found
error in the terminal.

The command:
mysql -uUNAME -pPASSWORD#PASS -e "SELECT * from TABLE_NAME" DB_NAME | sed 's/\t/","/g;s/^/"/;s/$/"/' > /Users/Desktop/name.csv


Need help! Thanks in advance.

Answer

You must escape special chars with backslash like

The command:

mysql -uUNAME -pPASSWORD\#PASS -e "SELECT * from TABLE_NAME" DB_NAME | sed 's/\t/","/g;s/^/"/;s/$/"/' > /Users/Desktop/name.csv
Comments