How to generate error log file while executing a .sql file in terminal 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 &lt; sq2.sql &amp;

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


Both queries run as a back-end daemon because of "&amp;" 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.
So after a little more searching I found the answer :)

Here is how this needs to be done.


mysql -uroot -xxx! -f main &lt; sq2.sql &gt; /var/www/log.txt &amp;