2 Added backup tag since mysqldump performs backups
| link
    Tweeted twitter.com/#!/StackDBAs/status/176409189894209537
1
source | link

How to log verbose output from mysqldump?

You typically save the verbose output of a Linux command like this:

# command > output.txt

But when you use a command like mysqldump, the > option outputs the dump of the database tables to the desired file:

# mysqldump --username=whatever --password=whatever -h localhost database > dump.sql

If you add in the -v (verbose) option to mysqldump, it outputs help information about what the command is doing. How do I save this verbose output to a file since the > option is used to output the database table information to a file?

More specifically, I'm dumping the output of one database into another database like this:

mysqldump -alv -h 123.123.123.123 --user=username --password=p@ssw0rd --add-drop-table databasename | mysql --user=username --password=p@ssw0rd -h localhost localdatabase

I tried the following but the output file was empty in the end

mysqldump -alv -h 123.123.123.123 --user=username --password=p@ssw0rd --add-drop-table databasename | mysql --user=username --password=p@ssw0rd -h localhost localdatabase > output.log

Also tried the following, but it redirected the database information to the output.log instead of the target databse:

mysqldump -alv -h 123.123.123.123 --user=username --password=p@ssw0rd --add-drop-table databasename > output.log | mysql --user=username --password=p@ssw0rd -h localhost localdatabase

And I don't see any sort of --log-file=FILE option for mysqldump either.