How to enable slow query log in mysql command line
Sep 30, 2020 am 09:28 AMMysql command line method to enable slow query log: Execute the [set global slow_query_log='ON';] statement to enable it. You can check whether the slow query log is enabled by executing the [show variables like "%slow%";] statement.
Specific method:
(Recommended tutorial: mysql tutorial)
Check the default slow speed The query time is 10 seconds
mysql> show variables like "%long%"; +-----------------+-----------+ | Variable_name | Value | +-----------------+-----------+ | long_query_time | 10.000000 | +-----------------+-----------+ 1 row in set (0.00 sec)
Set to 3 seconds, add global, exit and re-enter to take effect
mysql> set global long_query_time=3; Query OK, 0 rows affected (0.00 sec)
Check whether slow query has been enabled
mysql> show variables like "%slow%"; +---------------------+---------------------------------+ | Variable_name | Value | +---------------------+---------------------------------+ | log_slow_queries | OFF | | slow_launch_time | 2 | | slow_query_log | OFF | | slow_query_log_file | /usr/local/mysql/mysql-slow.log | +---------------------+---------------------------------+ 4 rows in set (0.00 sec)
Enable slow query
mysql> set global slow_query_log='ON'; Query OK, 0 rows affected (0.28 sec)
Check whether it has been enabled
mysql> show variables like "%slow%"; +---------------------+---------------------------------+ | Variable_name | Value | +---------------------+---------------------------------+ | log_slow_queries | ON | | slow_launch_time | 2 | | slow_query_log | ON | | slow_query_log_file | /usr/local/mysql/mysql-slow.log | +---------------------+---------------------------------+ 4 rows in set (0.00 sec)
Related recommendations: php training
The above is the detailed content of How to enable slow query log in mysql command line. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP's big data structure processing skills

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP?

How to insert data into a MySQL table using PHP?

What are the application scenarios of Java enumeration types in databases?

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP?

Performance optimization strategies for PHP array paging
