Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let me first start off by saying I am not an experienced linux user.

I am trying to debug a mysql script in linux, however, my issue is that most of the queries are successful so I can not see the error messages because they scroll off the screen. I am executing the queries from a large file using the \. command.

I was wondering if there was a way to show ONLY the error messages when I exececute the sql file. Right now it is showing both error messages and Query OK,....

I don't really care about the queries that are ok, just the errors.


share|improve this question

You didn't mention much about HOW you use it; but if the "scrolling off the screen" is the problem at hand: capture ALL output in a file.

<command> | tee output 2>&1
share|improve this answer
when I did: bash> mysql | tee output 2>&1 Nothing happened when I did mysql> \\. myfile.sql | tee output 2>&1 I got an error – TRWTFCoder Nov 8 '12 at 18:49
something like this: mysql --batch -e 'SHOW TABLES'; | tee output 2>&1. Also please mention WHAT error you're getting; with the info provided it's hard to diagnose. – tink Nov 8 '12 at 18:52

You might want to run mysql in batch mode (mysql -B), that makes it not give any output besides errors, not even a prompt.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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