MySQL – How to Generate Error Log File While Executing .sql File in Terminal

importMySQL

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.

Best Answer

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 &