cancel
Showing results for 
Search instead for 
Did you mean: 

mysql dump

Piotr Kirklewski
Super Advisor

mysql dump

Hi there

A nead to build command to backup mysql loging from remote host (host A), the files shoud be stored on host A but database exist at host b.
I was trying :

mysqldump -h myhost.com -u test -ptest2 test > /home/admin/

But it's not working.

Can anyone help ?
Jesus is the King
2 REPLIES
Stuart Browne
Honored Contributor

Re: mysql dump

I'm going to assume the username and password pair you're using are valid for the 'test' database..

With that, the only issue I really see is that you're trying to redirect to a directory, when you need to be redirecting to a file, i.e.

mysqldump -hmyhost.com -utest -ptest2 test > /home/admin/test-dump.sql

Depending on the table types, and how often the tables are used, you might want to look at '--opt' and '-q' flags to 'mysqldump'.
One long-haired git at your service...
Van den Broeck Tijl
Valued Contributor

Re: mysql dump

mysqldump needs a file to dump it's data in, not a directory.

If you want to load the dump on another host (say: Host B, which already has the same database) you can make it add a dropline for that database (BE SURE there is no vital information in that database as it's going to be dropped!!!) with option:
--add-drop-database

But I think you're talking about a full db export & import. --opt is recommended for that (also enables add-drop-table by default)

So you'd have something like:
mysqldump -h host -utest -ptest --add-drop-database --databases testdb > testdb.sql