How to make MySQL log to 2 separate remote servers? Documentation on this topic is scarce at best. I have two syslog servers and I need to send MySQL logs to them. Currently, I believe the logs are stored at either .mysql_history and/or mysqld.log Does mysql have the capability within itself to log remotely, or do I need to write a script to do so?

If mysql has this capability, it seems that you could only assign it to one location. I need two, so I would need to know if this is able to be done or just go with the script again.

I tried testing one server and tried setting environment variable MYSQL_HISTFILE location to one remote server; however, this is not working.

Any help or resources?
The .mysql_history file is only for commands in the mysql client, and only for the current operating system user. I don't know of any way to log this anywhere but in .mysql_history.

The mysqld.log can be written to the local syslog daemon, so it ends up in /var/log/messages (or wherever you send syslog). You enable this with the following entries in /etc/my.cnf:

[mysqld_safe]
syslog
syslog-tag = mysql


The syslog-tag is optional, but helpful so your mysql log entries are easily separated from other syslog entries. I like to name the tag something specific to the server, if I'm going to merge mysql logs from multiple instances into one remote syslog.

Then you can use rsyslog to send the syslog content (or only the subset of entries with the given tag) to another server. See http://www.rsyslog.com/storing-and-forwarding-remote-messages/



This question might also be helpful: send logs to multiple rsyslog servers