5
mysqldump -u censored -'p32dasdA)k+~Ow9' censored > backup.sql 

The above code results in error bash: syntax error near unexpected token `)'

I assume it's because the password contains certain characters, but I'm not sure how to resolve the issue. Also, where should I check for the backup after it's complete?

Any help is greatly appreciated.

6 Answers 6

10

Try this: mysqldump -u censored -p censored > backup.sql

Then enter the password when prompted. The syntax error comes from mysql seeing the '-' and looking for a valid option, when it gets to ')' it knows there is a problem and throws the syntax exception.

Sign up to request clarification or add additional context in comments.

3 Comments

I think that worked! After I entered the password it moved down to a new line. How will I know it worked? I'm not sure where to check for the backup...
I think the backup file will appear in the directory where you ran the command from. so if you are in ~, it should appear in ~. I think you can also pass a fully qualified path to the command, '\opt\mysql\backups'
If it works it will return to a new line waiting for a new command, if it fails you will get a message, you could also watch your current directory for the file.
2

I think you mean to use -p' instead of -'p, or maybe -p'p. It would also be more secure to not type the password in there but instead use -p with no argument and type the password when prompted.

Comments

1
mysqldump -u user -p password user > mysql.sql 

Comments

0
mysqldump -u censored -p 'p32dasdA)k+~Ow9' censored > backup.sql 

or

mysqldump -u censored -p '32dasdA)k+~Ow9' censored > backup.sql 

Comments

0

try this my friend:

mysqldump -u user -p 'database_name' > file.sql user = your username mysql 

2 Comments

While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value.
This doesn't address the question. The OP is trying to pass in the password, where you have omitted it entirely, assuming that they are able to supply a password interactively on the tty.
-1

Try the following:

mysqldump dbname -u username -p > backupfilename 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.