title: Is there any way to log queries and output to a file?
body: <p>My case is the following: an external party delivers a huge SQL file with thousands of queries. These include updates, inserts, subqueries, etc. Those queries are assembled in third-party software (I think Excel, but I might be mistaken). </p>
  
  <p>As a result, many of these queries tend to fail and the whole batch needs to succeed without one single error. I'm using <code>mysql source file.sql</code> to execute the queries, and I'm using <code>mysql tee log.txt</code> to log the output to a txt-file.</p>
  
  <p>However, this has proven to be insufficient, as this is the output I'm getting:</p>
  
  <pre><code>Query OK, 1 row affected (0.00 sec)
  
  Query OK, 0 rows affected (0.00 sec)
  
  Query OK, 1 row affected (0.00 sec)
  
  ERROR 1242 (21000): Subquery returns more than 1 row
  Query OK, 0 rows affected (0.00 sec)
  
  Query OK, 1 row affected (0.00 sec)
  
  Query OK, 0 rows affected (0.00 sec)
  </code></pre>
  
  <p>It's kinda looking for a needle in a haystack. I'd have to count all the preceding logging messages to determine which exact query failed.</p>
  
  <p>Is there any way to get a log file <em>including</em> the queries? Or is there another way of doing this efficiently?</p>
  
  <ul>
  <li>Executing in small batches is not an option. (It would take ages.)</li>
  <li>Executing them all on the commandline isn't either. (The messages fly by so fast it's impossible to read or capture them all.)</li>
  </ul>