Mysql – Is it possible to log thesql queries from other hosts in general log

logMySQL

I'm having a task to figure out what are the hosts that are still running scripts that accessing our database directly so we can prevent that from happening(we only want our web app to access the database but nothing else). I just learnt that enabling general_log would give me a nice table of access log. My problem is that the table grows too fast and easily lost control.

For my specific use case, my question would be: is there a mysql feature to make general_log only record database access from other hosts so general_log could record less data? I know it's pretty unlikely to happen, so my last option is to periodically delete the records that are local access. But this might cause performance issue. Do you think it makes sense to do that? Is there a better way to do it? Thanks.

Best Answer

You may use the mcaffee audit plugin https://github.com/mcafee/mysql-audit/wiki/Installation there you can filter hosts in logging.

You could also refuse all hosts specifying a mysql User with an appropriate Host. ('user'@'allowedHostIpRange').