[lug] Script to send apache logs to mysql

John Starkey jstarkey at advancecreations.com
Thu Jun 14 12:51:17 MDT 2001


> Try:
>
> #!/bin/bash
>
> /usr/bin/mysql -u user -p pazzword Apache <
>  "LOAD DATA INFILE '/path/to/apache/logs/mysql_format_log'
>   INTO TABLE access_log FIELDS TERMINATED BY ','  OPTIONALLY ENCLOSED BY
>  '\"' ESCAPED BY '''' "
>
> http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
>
> I haven't tested that this works with mysql, but it errors in the 'right'
> way in bash (No such file or directory).

Thanks Evelyn. I wasn't able to get it to work as one line so what I did
was put the second half in a file (without enclosing the whole statement
in double quotes) and just used:

mysql -u user -ppassword database < other_file

And executed that with cron. I also found out the hard way that MySQL
isn't very suited for this task (the amount of entries) in terms of speed.
Anyone reading this should heed warning -- use individual log files and
tables for each domain.

> > mod_log_mysql that does this now? 3 hours of google turned up only that
> > which I can't find an update for since 98. Apache has moved all their
> > headers around since and I can get to all but one. Can't find it anywhere.
> > os.h I believe.
>
> http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html

Yeah. I wrote the author and rec'd no reply. mod_log_mysql must be outta
the loop.

Thanks for the help,

John




More information about the LUG mailing list