# Syslog-ng 3.1 with MySQL



## nickrad (Sep 9, 2011)

Hello, I have installed syslog-ng3 from ports fine and logging to files is working great. However when i implement mysql logging it breaks. I have tried a few how-to's and looked over the documentation but can see where I am going wrong. I have tried both host="localhost" and host="127.0.0.1" for socket and tcp uses, same error.

The error received is...


```
Starting syslog_ng.
Unable to initialize database access (DBI); rc='-1', error='No such file or directory (2)'
Error initializing dest driver; dest='d_sql', id='d_sql#0'
Error initializing message pipeline;
/usr/local/etc/rc.d/syslog-ng: WARNING: failed to start syslog_ng
```


Here is the config for the destination d_sql



```
destination d_sql {
                sql(type(mysql)
                host("localhost") username("syslog") password("passwd")
                database("syslog")
                table("logs")
                columns("host", "facility", "priority", "level", "tag", "datetime", "program", "msg")
                values("$HOST", "$FACILITY", "$PRIORITY", "$LEVEL", "$TAG", "$ISODATE", "$PROGRAM", "$MESSAGE")
                indexes("host", "facility", "priority", "datetime", "program"));
                };
```


----------



## AndyUKG (Sep 9, 2011)

Hi,

  sorry, can't help on the problem. But for what its worth I can recommend *rsyslog *as an alternative. I have had this running with MySQL well for a few years. Perhaps it would also be a fit for your requirement....

thanks Andy.


----------



## czanik (Sep 12, 2011)

Do you have the libdbi-drivers package installed with mysql support enabled? Without it logging to mysql does not work. Syslog-ng uses libdbi for database access (which seems to be compiled and enabled if you don't get an error on your configuration), and libdbi uses libdbi-drivers for doing the actual database access.
-- 
Peter Czanik (CzP) <czanik@balabit.hu>
BalaBit IT Security / syslog-ng upstream
http://czanik.blogs.balabit.com/


----------



## nickrad (Sep 12, 2011)

That was it! Thanks.

libdbi was installed but not libdbi-drivers


----------

