MYSQL slow problem record database statements

  • 2020-05-12 06:22:54
  • OfStack

You need to turn on the output of a slow query: log_slow_queries. This can be set in the MySQL configuration file (my.ini/my.cnf) or temporarily via the MySQL client. The second approach has the advantage of enabling the Settings to take effect without restarting the MySQL service. Try this:
First connect to the Mysql server via the client, then enter the following statement:
SET GLOBAL log_slow_queries = ON;
SET GLOBAL long_query_time = 3;

So MySQL takes time > = the SQL statement of 3 seconds is recorded and output to a slow query log file. The question is, where is this slow query log file? Execute the following statement in the MYSQL client as follows:
show variables like 'slow_query_log_file';
You will see that MySQL is slow to query the log file location. I: / usr/local/mysql/data/host - slow. log

Related articles: