Using MySQL With Apache
- There are programs that authenticate users from a MySQL database and also allow log files to write into a MySQL table.
- Making the Apache logging format easily readable by MySQL is done by putting the following into the Apache configuration file.
LogFormat "\"%h\",%{%Y%m%d%H%M%S}t,%>s,\"%b\",\"%{Content-Type}o\", \ \"%U\",\"%{Referer}i\",\"%{User-Agent}i\""
- To load a log file in that format into MySQL, use a statement like this:
LOAD DATA INFILE '/local/access_log' INTO TABLE tbl_name FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\';
- The named table should be created to have columns that correspond to those that the
LogFormat line writes to the log file.
Let us review the chapter.
© 2007 John Michael Pierobon
Notes