MySQL Forums
Forum List  »  General

error logging
Posted by: Bernd Schneider
Date: November 09, 2010 12:50PM

Hi,

I'm new to mysql and I am wondering if there is any possibility to catch "usual" ERRORs in SQL-Statements while working on commandline.

First I modified the server config (my.cnf), setting the following:

log = /var/log/mysql/mysql.log
log-error = /var/log/mysql/mysql.err
log-warnings

After one hour of testing and reading the manual I realized, that (apart from performance issues) mysql.log was logging all statements _without_ any error messages (for example in case of SQL systax errors) and _without_ any possibility to change the log level. mysql.err was logging server startup/shutdown notices only. I could not find any way to to log error messages together with the causing statements. Is there any way to do so?


Furthermore I am looking for a way to catch the commandline interface messages. Connecting to mysql via commandline gives lets me execute single statements or execute sql files.

For example:
----------------------------------------
mysql> source file.sql
Query OK, 1 row affected (0.00 sec)

Database changed
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 1495 rows affected (0.35 sec)
Records: 1495 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.00 sec)

ERROR 1298 (HY000): Unknown or incorrect time zone: 'NULL'
ERROR 1231 (42000): Variable 'sql_mode' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'foreign_key_checks' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'unique_checks' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'character_set_client' can't be set to the value of 'NULL'
Query OK, 0 rows affected (0.00 sec)

ERROR 1231 (42000): Variable 'collation_connection' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'sql_notes' can't be set to the value of 'NULL'
----------------------------------------

Is there any way to catch or pipe these messages into a file to grep it later for ERROR entries? I tried to pipe the sql file into mysql by typing:

# mysql -v --user=user --password=pass < file.sql

but even with the verbose argument I do not get the ERROR messages.

Thank you for your help!
Bernd



Edited 4 time(s). Last edit at 11/09/2010 01:06PM by Bernd Schneider.

Options: ReplyQuote


Subject
Written By
Posted
error logging
November 09, 2010 12:50PM
November 13, 2010 11:47PM
November 15, 2010 09:11AM
November 15, 2010 01:53PM
November 16, 2010 01:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.