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.
Best Answer
Your 1st mysqldump makes table structures and INSERTs and puts it in dump.sql.
Your 2nd dump is a remote dump that is piped straight into mysql in localhost.
If you are trying to catch any output based on errors, try this:
Using
2>
will catch any error-based output (aka stderr). The mysqldump should still pipe normal console output (aka stdout) to the other mysql session and load the data as intended.EXAMPLE : I have a small database called sample on my PC.
I ran this:
Give it a Try !!!