I just started learning coding 2 week ago and I am in a middle of an issue that I am not really able to find online, SO i though why not ask.

I am trying to import Import a MySql DB of around 8 Gigs through Terminal (SSH) But the file execution always stop in the middle somewhere.

My Question is: Is there a way to write the error log generated my mysql while running the query in terminal backend? The 2 queries I am using are:

1/mysql -uroot -pxxx -f main < sq2.sql &

2/ gzip -dc < file.sql.gz | mysql -f -uroot -pxxx web & 

Both queries run as a back-end daemon because of "&" and "-f" helps in forcing the mysql to run even when an error is encountered.

But still my query gets terminated in the middle, So how can I write and log errors for such commands.

2 Answers 2


So after a little more searching I found the answer :)

Here is how this needs to be done.

mysql -uroot -xxx! -f main < sq2.sql > /var/www/log.txt &

Just as little add , try to use append(>>) in order to maintain your old history log :

mysql -uroot -xxx! -f main < sq2.sql >> /var/www/log.txt &

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.