Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL slow queries aren't logged

In my CentOS machine I use MySQL 5.5.30. (I rented server two days ago and I'm newbie in Linux commands)

I'm trying to check for slow MySQL queries. So I made this from phpMyAdmin

SET GLOBAL log_slow_queries = ON;
SET GLOBAL slow_launch_time = 1;
FLUSH LOGS;

And in default configuration slow query log file variable is /var/lib/mysql/srv1-slow.log

But when I check /var/ folder with FTP, there exists only /var/tmp/ folder. which is empty. What should I do more to see slow queries log?

Note: I tried to create /var/lib folder but system didn't let me.

like image 607
trante Avatar asked Nov 16 '25 21:11

trante


1 Answers

Add following lines in /etc/my.cnf and restart mysql:

Notes: In my case MySQL version is 5.0.x

[mysqld]

    log-slow-queries = /var/lib/mysql/sev1-slow.log
    long_query_time = 1

In MySQL 5.5 version

[mysqld]

    slow_query_log_file= = /var/lib/mysql/sev1-slow.log
    long_query_time = 1
    slow_query_log = 1

You must create the file manually and change owners this way:

mkdir /var/lib/mysql
touch /var/lib/mysql/sev1-slow.log
chown mysql.mysql -R /var/lib/mysql
like image 142
Satish Avatar answered Nov 19 '25 11:11

Satish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!