mysql 中需要什么命令才能将中止的连接和拒绝访问的日志写入系统日志?
最佳答案
命令先看看你的设置是什么:
select @@general_log; -- a 1 indicates it is turned on for capture
select @@general_log_file; -- the file that it logs to
select @@datadir; -- directory location where the log lives
为 General Query Log 打开日志记录,使用以下内容:
SET GLOBAL general_log = 'ON'; -- 0 is off, 1 is on
请注意,datadir
是只读的,更改后需要重启服务器。基本上,不要改变这个。它是您的数据库架构的所在地。
对于扩展的连接失败执行
select @@log_warnings; -- make a note of your prior setting
set global log_warnings=2; -- setting above 1 increases output
上面直接与写在同一数据目录中的错误日志有关。
请参阅 Percona 文章 Auditing login attempts in MySQL和我之前的回答Here .
关于mysql - 启用 MySQL 系统日志以记录中止的连接和拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38380684/