show variables like 'log_error';
+---------------+--------------------------+ | Variable_name | Value | +---------------+--------------------------+ | log_error | /var/log/mysql/error.log | +---------------+--------------------------+
cat /var/log/mysql/error.log | more
151110 14:44:15 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 2015-11-10T03:44:15.916141Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2015-11-10T03:44:15.916275Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000) 2015-11-10T03:44:16.831947Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2015-11-10T03:44:16.832003Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 2015-11-10T03:44:16.837216Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.9) starting as process 22405 . … … … … …
show variable like 'general_log';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | general_log | OFF | +---------------+-------+
set global general_log='ON';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | general_log | ON | +---------------+-------+
show variables like 'log_output';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_output | FILE | +---------------+-------+
show variables like 'general_log_file';
+------------------+---------------------------------------+ | Variable_name | Value | +------------------+---------------------------------------+ | general_log_file | /var/lib/mysql/csit115-VirtualBox.log | +------------------+---------------------------------------+
set global log_output='TABLE';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_output | TABLE | +---------------+-------+
DESCRIBE mysql.general_log;
+--------------+---------------------+------+-----+----------------------+--------------------------------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------------------+------+-----+----------------------+--------------------------------+ | event_time | timestamp(6) | NO | | CURRENT_TIMESTAMP(6) | on update CURRENT_TIMESTAMP(6) | | user_host | mediumtext | NO | | NULL | | | thread_id | bigint(21) unsigned | NO | | NULL | | | server_id | int(10) unsigned | NO | | NULL | | | command_type | varchar(64) | NO | | NULL | | | argument | mediumblob | NO | | NULL | | +--------------+---------------------+------+-----+----------------------+--------------------------------+
TRUNCATE TABLE mysql.general_log;
SELECT * FROM mysql.general_log;
+----------------------------+---------------------------+-----------+-----------+...
| event_time | user_host | thread_id | server_id |
+----------------------------+---------------------------+-----------+-----------+...
| 2017-05-08 14:14:45.546765 | root[root] @ localhost [] | 3 | 0 |
+----------------------------+---------------------------+-----------+-----------+...
...--------------+---------------------------------+
... command_type | argument |
...--------------+---------------------------------+
... Query | select * from mysql.general_log |
...--------------+---------------------------------+
set global general_log='OFF'
show variables like 'general_log';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | general_log | OFF | +---------------+-------+
show variables like long_query_time;
+-----------------+-----------+ | Variable_name | Value | +-----------------+-----------+ | long_query_time | 10.000000 | +-----------------+-----------+
show varfiables like min_examined_row_limit;
+------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | min_examined_row_limit | 0 | +------------------------+-------+
SET long_query_time = 0 SHOW VARIABLES LIKE 'long_query_time';
+-----------------+----------+ | Variable_name | Value | +-----------------+----------+ | long_query_time | 0.000000 | +-----------------+----------+
show variables like 'slow_query_log';
+----------------+-------+ | Variable_name | Value | +----------------+-------+ | slow_query_log | OFF | +----------------+-------+
set global slow_query_log='ON'
show variables like 'slow_query_log';
+----------------+-------+ | Variable_name | Value | +----------------+-------+ | slow_query_log | ON | +----------------+-------+
show variables like 'log_output'
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_output | FILE | +---------------+-------+
show variables like 'slow_query_log_file'
+---------------------+--------------------------------------------+ | Variable_name | Value | +---------------------+--------------------------------------------+ | slow_query_log_file | /var/lib/mysql/csit115-VirtualBox-slow.log | +---------------------+--------------------------------------------+
set global log_output='TABLE'
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_output | TABLE | +---------------+-------+
DESCRIBE mysql.slow_log
+----------------+---------------------+------+-----+----------------------+--------------------------------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+----------------------+--------------------------------+ | start_time | timestamp(6) | NO | | CURRENT_TIMESTAMP(6) | on update CURRENT_TIMESTAMP(6) | | user_host | mediumtext | NO | | NULL | | | query_time | time(6) | NO | | NULL | | | lock_time | time(6) | NO | | NULL | | | rows_sent | int(11) | NO | | NULL | | | rows_examined | int(11) | NO | | NULL | | | db | varchar(512) | NO | | NULL | | | last_insert_id | int(11) | NO | | NULL | | | insert_id | int(11) | NO | | NULL | | | server_id | int(10) unsigned | NO | | NULL | | | sql_text | mediumblob | NO | | NULL | | | thread_id | bigint(21) unsigned | NO | | NULL | | +----------------+---------------------+------+-----+----------------------+--------------------------------+
TRUNCATE TABLE mysql.slow_log;
SELECT query_time, sql_text FROM mysql.slow_log
+-----------------+-------------------------------------------------+ | query_time | sql_text | +-----------------+-------------------------------------------------+ | 00:00:00.034088 | truncate table mysql.slow_log | | 00:00:00.000870 | select * from mysql.slow_log | | 00:00:00.000914 | select query_time, sql_text from mysql.slow_log | +-----------------+-------------------------------------------------+
set global slow_query_log='OFF'
show variables like 'slow_query_log';
+----------------+-------+ | Variable_name | Value | +----------------+-------+ | slow_query_log | OFF | +----------------+-------+