How To Enable MySQL General Query Log On Linux

0
252

How To Enable MySQL General Query Log On Linux

The Server writes information to this file when the client connects and disconnects. MySQL query used to find out the error in a client and want to know what exactly the client sent to mysqld. This writes to log each SQL statement received from the client. Let’s see how to enable the MySQL general query log example.

You can Enable Query Log for MySQL below 5.1.29 Version, Then use the below settings in [mysqld] section.

Check Out: How To Enable Slow Query In MySQL Server In Linux 

There’re many log formats for MySQL logs which can help you to find out the issues in the database or in tables.

Method 1: you can add permanently in my.cnf file.

vim /etc/my.cnf
log = /home/general-query.log

Set via MySQL Console,

SET general_log = 1;

Start the Service

systemctl restart mysqld

Check Out: Solve MySQL Too Many Connections Error On Redhat 7

Method 2: You can Enable General Queries for MySQL above 5.1.29

version.

general_log_file = /path/to/general-query.log
general_log = 1

Set via MySQL Console,

SET general_query_log = 1;

Check Out: Install MySQL 5.6 Database Server Using Repository In Linux

Create a file general-query.log where you want to keep these logs.

touch general-query.log
chown -R mysql:mysql general-query.log
systemctl restart mysqld

YouTube Link:

You’re done

LEAVE A REPLY

Please enter your comment!
Please enter your name here