At 21:35 -0500 1/7/04, Asif Iqbal wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Paul DuBois wrote:
At 20:39 -0500 1/7/04, Asif Iqbal wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Hi All
>
>I have been using mysql database to collect my syslog data. It was
>working fine. However recently I had few logs that had apotrophe and I
>failed to insert those lines into my database. It said syntax error. Is
>there any patch anything I can put and recompile mysql so it won't fail
>while inserting log lines that has apotrophe (') in it ?
MySQL is acting properly. If you don't escape apostophes in your data
values
properly, the query is not syntactically legal.
However, we cannot advise you how to deal with this without more
information.
Can you tell us how you're attempting to insert the log data into MySQL?
Are you using some script that you have written, for example? What language
is it in?
I am using a fifo /tmp/mysql.pipe to push my syslog data directly into
my database
Here is the relevant syslog-ng config file
source net { udp (ip(208.47.0.114) port(514)); };
destination d_mysql {
pipe("/tmp/mysql.pipe"
template("INSERT INTO logs (host, facility, priority, level, tag, date,
time, program, msg) VALUES ( '$HOST', '$FACILITY', '$PRIORITY',
'$LEVEL', '$TAG',
'$YEAR-$MONTH-$DAY', '$HOUR:$MIN:$SEC', '$PROGRAM', '$MSG' );\n")
template-escape(yes));
};
log { source(net); destination(d_mysql); };
Here is my syslog database
CREATE DATABASE syslog;
USE syslog;
CREATE TABLE logs (
host varchar(32) default NULL,
facility varchar(10) default NULL,
priority varchar(10) default NULL,
level varchar(10) default NULL,
tag varchar(10) default NULL,
date date default NULL,
time time default NULL,
program varchar(15) default NULL,
msg text,
seq int(10) unsigned NOT NULL auto_increment,
PRIMARY KEY (seq),
KEY host (host),
KEY seq (seq),
KEY program (program),
KEY time (time),
KEY date (date),
KEY priority (priority),
KEY facility (facility)
) TYPE=MyISAM;
This is how I am piping the log into the database
mysql -u root --password=passwd syslog < /tmp/mysql.pipe
It was working fine until it saw a apostrophe in the log and then failed
to insert
I am using mysql Ver 12.22 Distrib 4.0.17, for sun-solaris2.7 (sparc)
Basically syslog-ng does exactly what it suppose to do. collect the logs
from the source and send it to the destination which is happened to be a
pipe to the mysql database. So there is no language in the middle
I don't think that's going to work. You need to have some mechanism
that can properly escape data values in case they contain stuff like
apostrophes.
--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
MySQL Users Conference: April 14-16, 2004
http://www.mysql.com/uc2004/
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]