How to store mysql 'slow_query_log' file under '/var/log' directory

shivakumar7

Registered
Apr 19, 2022
3
0
1
Bangalore
cPanel Access Level
Root Administrator
Hi Team ,
By default mysql 'slow_query_log' file gets stored in '/var/lib/mysql' directory but what i needed was 'slow_query_log' file should get recorded under '/var/log/mysql/' directory .
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
12,499
1,971
363
cPanel Access Level
Root Administrator
Hey there! You can adjust the following values in the /etc/my.cnf file to change that log location:

To enable the log:
Code:
slow_query_log=1
To change the log location:
Code:
slow_query_log_file=/full/path/to/log/file
You'll want to make sure the log file exists and has the correct MySQL ownership and permissions. For example, the main /var/log/mysqld.log file on a test system looks like this:

Code:
-rw-r-----. 1 mysql mysql 18K Apr 26 05:34 /var/log/mysqld.log
You'll need to restart the MySQL server after making those changes.
 
  • Like
Reactions: Spirogg