mysql - 启用 MySQL 系统日志以记录中止的连接和拒绝访问

标签 mysql linux

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/

相关文章:

mysql - SQL查询: Delete all records from the table except latest N?

mysql - 如何在MYSQL 5.7中为不同 channel 设置不同的replication_do_db?

linux - linux 中的 iomapped 内存系统调用失败。

c++ - Eclipse Indigo C++ 的指标

mysql 在update 语句中使用cast 时出现错误1292

PHP 函数调用 sql SUM 不起作用

java - 区分Linux上Java应用程序映射内存和JVM映射内存

linux - Qt程序只接收来自特定IP地址的UDP

regex - 打印相关符号之前的所有内容,并在相关符号之后保留 1 个字符

mysql - 对具有多个主键的表进行子查询