標籤:http os ar for 檔案 art log ad ef
很多時候,我們需要知道 MySQL 執行過哪些 SQL 陳述式,比如 MySQL 被注入後,需要知道造成什麼傷害等等。只要有 SQL 陳述式的記錄,就能知道情況並作出對策。伺服器是可以開啟 MySQL 的 SQL 陳述式記錄功能,從而就能間接地檢測到用戶端程式的行為。淶水縣梁以紙業
開啟方法很簡單:編輯/etc/my.cnf檔案,在[mysqld]節下面添加:log=/var/lib/mysql/sql_row.log行(日誌的路徑自己根據需要定義)。
[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Default to using old password format for compatibility with mysql 3.x# clients (those using the mysqlclient10 compatibility package).old_passwords=1log=/var/lib/mysql/sql_row.log# Disabling symbolic-links is recommended to prevent assorted security risks;# to do so, uncomment this line:# symbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
修改完畢後,記得重啟 MySQL:
service mysql restart# 或者/etc/init.d/mysqld stop/etc/init.d/mysqld start
現在你去 /var/lib/mysql/ 路徑下的 sql_row.log 檔案應該是能夠看到 MySQL 什麼時候執行了哪些程式了。
如何記錄MySQL執行過的SQL語句