3

I get this error bash on my virtual hosting, in cron tasks. My command is following:

/usr/bin/mysqldump --user=USERNAME --password="C\(mRA0_ifmv\(" DATABASE > ROOTFOLDER/backup/$(date +%F).sql && gzip ROOTFOLDER/backup/$(date +%F).sql

I hid real user, database and home folder for security purposes. So, I understand that my password causes this error, but I don't want to change it.

How can I escape open bracket char or avoid this error and why "\" doesn't work?

wapmorgan
  • 33
  • 1
  • 5
  • 1
    From `man mysqldump`: __Specifying a password on the command line should be considered insecure.__ See Section 6.1.2.1, “End-User Guidelines for Password Security”. You can use an option file to avoid giving the password on the command line. – Hastur Oct 14 '15 at 17:06
  • Concur. Your problem here is that you're using `--password=` in the first place. Use an ini file instead and the entire issue goes away AND becomes more secure. – Shadur Oct 16 '15 at 09:22

1 Answers1

2

Use single quotes for the password.

--password='C\(mRA0_ifmv\('

Bash Manual: Single Quotes

Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.

Bash Manual: Double Quotes

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’.

Steven
  • 27,531
  • 11
  • 97
  • 118