今天开发问我,MySQL有无操作日志可查,呵呵,当然有了,不过默认情况下是没有开启的,开启步骤如下:
1,在/etc/my.cnf mysqld后面添加log = /var/lib/mysql/mysql.log
2,重启mysql
3,验证是否正常
[root@youxia64 ~]# mysql -uroot -p123456 abc;
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.24-rc-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select * from Account limit 1;
+-------+-------------------------------------+--------+-------+----------------+---------------------+---------------------+--------+-----------+---------+------+--------+----------+------------+
| accId | accName | passwd | email | loginIp | createDttm | lastLoginDttm | status | partnerId | purview | cash | markId | serverId | unLockTime |
+-------+-------------------------------------+--------+-------+----------------+---------------------+---------------------+--------+-----------+---------+------+--------+----------+------------+
| 1 | 9ff37eb3806ad3c2f5f67327b280_120013 | | empty | 119.161.225.60 | 2009-07-29 11:20:27 | 2009-08-05 11:57:04 | 1 | 120013 | 0 | 0 | NULL | 0 | NULL |
+-------+-------------------------------------+--------+-------+----------------+---------------------+---------------------+--------+-----------+---------+------+--------+----------+------------+
1 row in set (0.00 sec)
mysql>
[root@web mysql]# cat mysql.log
/usr/sbin/mysqld, Version: 5.1.24-rc-community-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
1 Query select @@version_comment limit 1
100309 11:14:18 1 Query select * from Account limit 1
100309 11:14:19 1 Quit