
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to enable MySQL Query Log?
To enable query log, use the command SET global. You cannot use set general_log in MySQL version 8.0.12 version. If you are using version 8.0.12, then you will get the below given error. Here, we are trying to set general_log to see what error will come −
mysql> SET general_log = 1;
The following is the output −
ERROR 1229 (HY000): Variable 'general_log' is a GLOBAL variable and should be set with SET GLOBAL
Now, we will use the global command with general_log. The query is as follows −
mysql> SET global general_log = 1; Query OK, 0 rows affected (0.10 sec)
To check it is enabled or not, use the SHOW command −
mysql> SHOW variables like '%general_log%';
The following is the output −
+------------------+---------------------+ | Variable_name | Value | +------------------+---------------------+ | general_log | ON | | general_log_file | DESKTOP-QN2RB3H.log | +------------------+---------------------+ 2 rows in set (0.03 sec)
From the above sample output, you can see that it got enabled by giving value 1. We can disable it by giving the value 0. The following is the query to disable −
mysql> SET global general_log = 0; Query OK, 0 rows affected (0.06 sec)
Now let us check the same using the following query −
mysql> SHOW variables like '%general_log%';
The following is the output −
+------------------+---------------------+ | Variable_name | Value | +------------------+---------------------+ | general_log | OFF | | general_log_file | DESKTOP-QN2RB3H.log | +------------------+---------------------+ 2 rows in set (0.00 sec)
- Related Articles
- How can I enable MySQL slow query log without restarting MySQL?
- Enable MySQL Compression
- How to log in as a different user on MySQL?
- Enable TLS for MySQL Clients
- How to know if MySQL binary log is enabled through SQL command?
- How can I install or enable innoDB in MySQL?
- How to query soundex() in MySQL?
- How to remove scientific notation from a Matplotlib log-log plot?
- How can we ENABLE AND DISABLE a particular MySQL event?
- Turn on the general log in MySQL?
- How to measure actual MySQL query time?
- How to query JSON datatype in MySQL?
- How to treat MySQL longtext as integer in MySQL query?
- How to enable Bluetooth in android?
- How to enable wifi in android?

Advertisements