• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

MySQL - how to suppress informational messages

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    MySQL - how to suppress informational messages

    I have a large file containing SQL statements to create a few MySQL tables and it is spitting out a gazillion messages like this:

    Code:
    Query OK, 1 row affected (0.00 sec)
    How do I suppress this lot?

    I could redirect them to a file, but it's still a lot of processing, and there's 750 MB of input file. Surely there's a simple and low overhead way.
    Behold the warranty -- the bold print giveth and the fine print taketh away.

    #2
    Originally posted by Sysman View Post
    I have a large file containing SQL statements to create a few MySQL tables and it is spitting out a gazillion messages like this:

    Code:
    Query OK, 1 row affected (0.00 sec)
    How do I suppress this lot?

    I could redirect them to a file, but it's still a lot of processing, and there's 750 MB of input file. Surely there's a simple and low overhead way.
    OS X | Linux | Other Unix variants:

    Code:
    $verbosescript > /dev/null
    Windows | MS-DOS | CP/M:

    Code:
    C:\>verbosescript > NUL

    Comment


      #3
      Thanks Nick. Tons faster, even though it leaves me not knowing whether there were any errors in there. Off to count the INSERTs in the source now

      I was hoping for something option to only spit out the errors. ISTR reading about a build option to omit the MySQL stats for every operation but I can't find it right now...
      Behold the warranty -- the bold print giveth and the fine print taketh away.

      Comment


        #4
        Originally posted by Sysman View Post
        Thanks Nick. Tons faster, even though it leaves me not knowing whether there were any errors in there. Off to count the INSERTs in the source now

        I was hoping for something option to only spit out the errors. ISTR reading about a build option to omit the MySQL stats for every operation but I can't find it right now...
        I would expect it's sending errors to stderr rather than stdout. If so, you can redirect stdout to /dev/null and stderr to a file; it would vary depending on the shell, but I think the bash way of doing that would be something like:

        Code:
        $verbosescript 1> /dev/null 2> errors.txt
        EDIT: I just checked in bash, and the above does work for my test - I didn't test with MySQL but I assume it sends error messages to stderr, so that should work.
        Last edited by NickFitz; 15 October 2010, 16:15.

        Comment


          #5
          Originally posted by NickFitz View Post
          I would expect it's sending errors to stderr rather than stdout. If so, you can redirect stdout to /dev/null and stderr to a file; it would vary depending on the shell, but I think the bash way of doing that would be something like:

          Code:
          $verbosescript 1> /dev/null 2> errors.txt
          EDIT: I just checked in bash, and the above does work for my test - I didn't test with MySQL but I assume it sends error messages to stderr, so that should work.
          And the real answer is that I was trying to use the SOURCE command from the mysql> prompt. If I use the following instead, all those informationals disappear and errors such as "Table already exists" and "Duplicate entry 'xx' for key 'PRIMARY'" are displayed:

          Code:
          $mysql -u username < test.sql
          It does conk out straight away if it encounters a syntax error.

          Edit: I did this on Windows BTW
          Last edited by Sysman; 18 October 2010, 11:14.
          Behold the warranty -- the bold print giveth and the fine print taketh away.

          Comment

          Working...
          X