MySQL slow queries are not logged

On my CentOS machine, I am using MySQL 5.5.30. (I rented a server two days ago and I'm new to Linux commands)

I am trying to test slow MySQL queries. So I did it from phpMyAdmin

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

      

And in the default configuration the slow query log file

variable/var/lib/mysql/srv1-slow.log

But when I check the folder /var/

with FTP, only the folder exists /var/tmp/

. which is empty. What can I do to see the slow query log?

Note. I tried to create a folder /var/lib

, but the system wouldn't let me.

+3


source to share


1 answer


Add the following lines to /etc/my.cnf

and restart mysql:

Notes: In my case the MySQL version is 5.0.x

[mysqld]

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

      

As of MySQL 5.5



[mysqld]

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

      

You have to create the file manually and change the owner as follows:

mkdir /var/lib/mysql
touch /var/lib/mysql/sev1-slow.log
chown mysql.mysql -R /var/lib/mysql

      

+5


source







All Articles