Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export mysql database

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.

like image 922
user1446650 Avatar asked Sep 15 '13 20:09

user1446650


People also ask

How do I transfer MySQL database to another computer?

To copy a MySQL database from a server to another, you use the following steps: Export the database on the source server to a SQL dump file. Copy the SQL dump file to the destination server. Import the SQL dump file to the destination server.


2 Answers

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.

like image 185
OpenCoderX Avatar answered Oct 12 '22 12:10

OpenCoderX


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.

like image 40
Explosion Pills Avatar answered Oct 12 '22 11:10

Explosion Pills