Logs

MySQL LOG TYPES

Type Log Written to file
  1. Error log
Problems due to starting, running, or stopping mysqld instances
2. General query log Established client connections and statements received from clients
3. Binary log Statements that change data (replication)
4. Relay log Data changes received from a replication master server
5. Slow query log Queries that took more than long_query_time seconds to execute
6. DDL log (metadata log) Metadata operations performed by DDL statements

LOG OUTPUT : log_output

mysql> show variables like '%log_output%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | FILE |
+---------------+-------+
1 row in set (0.00 sec)

The value can be a comma-separated list of one or more of the words TABLE (log to tables), FILE (log to files), or NONE (do not log to tables or files

DEFAULT : FILE

IF FILE, it will save appropriate logs into file

IF TABLE, will save all details in pre defined tables.

EX: FILE

mysql> show variables like '%slow_query_log_file%' ;
+---------------------+-----------------------------------+
| Variable_name | Value |
+---------------------+-----------------------------------+
| slow_query_log_file | /var/lib/mysql/localhost-slow.log |
+---------------------+-----------------------------------+
1 row in set (0.00 sec)

The above result showing slow query log is enabled and it will be log in file at /var/lib/mysql/localhost-slow.log location.

log_output: TABLE

mysql> SET GLOBAL log_output = 'TABLE';
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%log_output%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | TABLE |
+---------------+-------+
1 row in set (0.00 sec)

IF log_outout is table it will log all logs to appropriate pre-defined standard tables

EX:  Pre defined Tables

  • mysql.general_log,
  • mysql.slow_log;

Leave a Reply

Your email address will not be published. Required fields are marked *