-
通用日志设置
my.cnf配置如下
general_log=on
general_log_file=/opt/mysql/data/mysql_general.log以下是通过查看日志得到的,可以看到记录了所有的SQL及各种query
[root@hack data]# tail -f mysql_general.log
/usr/local/mysql/bin/mysqld, Version: 5.6.14-log (Source distribution). started with:
Tcp port: 3306 Unix socket: /usr/local/mysql/mysql.sock
Time Id Command Argument
150417 0:53:55 1 Connect root@localhost on
1 Query select @@version_comment limit 1
150417 0:53:59 1 Query show databases
150417 0:54:11 1 Query select * from mysql.user
150417 0:54:31 1 Query select @@session.long_query_timemysql> show variables like '%general%';
+------------------+-----------------------------------+
| Variable_name | Value |
+------------------+-----------------------------------+
| general_log | ON |
| general_log_file | /opt/mysql/data/mysql_general.log |
+------------------+-----------------------------------+
2 rows in set (0.10 sec)
mysql> set @@session.general_log=off;
ERROR 1229 (HY000): Variable 'general_log' is a GLOBAL variable and should be set with SET GLOBAL
mysql> set @@global.general_log=off;
Query OK, 0 rows affected (0.01 sec)
mysql> 从这个也可以看到general_log为global参数 -
出错日志默认是开启的默认名为HOSTNAME.err 如果指定 log=/opt/mysql/data/mysql.log
my.cnf配置 log-error=/opt/mysql/data/mysql.log
[root@hack data]# tail -200f mysql.log 可以看到该日志记录关闭和开启数据库数据
150417 01:02:28 mysqld_safe Starting mysqld daemon with databases from /opt/mysql/data
2015-04-17 01:02:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-04-17 01:02:55 2701 [Note] InnoDB: 5.6.14 started; log sequence number 13384393
2015-04-17 01:02:56 2701 [Note] Server hostname (bind-address): '*'; port: 3306
2015-04-17 01:02:57 2701 [Note] IPv6 is available.
2015-04-17 01:02:57 2701 [Note] - '::' resolves to '::';
2015-04-17 01:02:57 2701 [Note] Server socket created on IP: '::'.
2015-04-17 01:03:00 2701 [Note] Event Scheduler: Loaded 0 events
2015-04-17 01:03:00 2701 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.6.14-log' socket: '/usr/local/mysql/mysql.sock' port: 3306 Source distribution
2015-04-17 01:04:41 2701 [Note] /usr/local/mysql/bin/mysqld: Normal shutdown
2015-04-17 01:04:41 2701 [Note] Giving 1 client threads a chance to die gracefully
2015-04-17 01:04:41 2701 [Note] Event Scheduler: Purging the queue. 0 events
2015-04-17 01:04:41 2701 [Note] Shutting down slave threads
2015-04-17 01:04:43 2701 [Note] Forcefully disconnecting 1 remaining clients
2015-04-17 01:04:43 2701 [Warning] /usr/local/mysql/bin/mysqld: Forcing close of thread 1 user: 'root'
2015-04-17 01:04:43 2701 [Note] Binlog end
2015-04-17 01:04:43 2701 [Note] Shutting down plugin 'partition'
2015-04-17 01:04:43 2701 [Note] InnoDB: FTS optimize thread exiting.
2015-04-17 01:04:43 2701 [Note] InnoDB: Starting shutdown...
2015-04-17 01:04:44 2701 [Note] InnoDB: Shutdown completed; log sequence number 13415235
2015-04-17 01:04:44 2701 [Note] Shutting down plugin 'binlog'
2015-04-17 01:04:44 2701 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
150417 01:04:45 mysqld_safe mysqld from pid file /opt/mysql/data/hack.pid ended关于error的参数
mysql> show variables like '%error%';
+--------------------+---------------------------+
| Variable_name | Value |
+--------------------+---------------------------+
| error_count | 0 |
| log_error | /opt/mysql/data/mysql.log |
| max_connect_errors | 100 |
| max_error_count | 64 |
| slave_skip_errors | OFF |
+--------------------+---------------------------+
5 rows in set (0.00 sec)
mysql>
本文转自 aklaus 51CTO博客,原文链接:http://blog.51cto.com/aklaus/1633622