mysql--通用日志(查询日志)

环境:

centos6.4 32位

mysql5.1

通用日志:记录连接数据库信息,和所有的操作

host' (using password: NO)
140814 15:32:24     2 Connect   root@localhost on test
                    2 Query     show databases
                    2 Query     show tables
                    2 Field List        a
                    2 Field List        dept
                    2 Field List        emp
                    2 Field List        salgrade
                    2 Query     show variables like '%log%'

开启日志:

my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#慢查询
long_query_time=1
log-slow-queries=/var/run/mysqld/mysqld-slow.log
#通用查询

log=/var/lib/mysql/mysql.log

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

note: 一般mysql日志一般放到 /var/lib/mysql 目录下,不然会因为权限问题报错

/usr/libexec/mysqld: File '/usr/local/mysql_log/mysql.log' not found (Errcode: 13)

通用查询日志不会自动创建日志文件,所以需要写脚本每天备份并重新创建日志文件,避免日志文件过大。



你可能感兴趣的:(mysql)