{"id":218,"date":"2026-06-02T23:14:45","date_gmt":"2026-06-03T06:14:45","guid":{"rendered":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/"},"modified":"2026-06-02T23:14:45","modified_gmt":"2026-06-03T06:14:45","slug":"how-to-enable-mysql-slow-query-log","status":"publish","type":"post","link":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/","title":{"rendered":"How to Enable MySQL Slow Query Log (and Actually Use It)"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>The MySQL slow query log records any SQL query that takes longer than a defined execution time. It&#8217;s one of the most reliable tools for MySQL performance debugging \u2014 especially when a site is intermittently slow and you can&#8217;t reproduce the issue on demand.<\/p>\n<p>You&#8217;ll typically need this when a WordPress site starts timing out, an application slows down under load, or a developer reports that database queries are taking seconds instead of milliseconds. The log doesn&#8217;t lie: it shows you the exact query, how long it ran, and how many rows it examined.<\/p>\n<p>This guide covers enabling the slow query log on MySQL 8.0+ and MariaDB 10.6+ via config file and live SQL commands. It applies whether you&#8217;re on a cPanel shared server, a <a href=\"https:\/\/www.hostandtech.com\/vps-ssd-servers\">VPS SSD Hosting<\/a> plan, or a dedicated server.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>SSH access to the server, or access to MySQL as a user with <code class=\"\" data-line=\"\">SUPER<\/code> or <code class=\"\" data-line=\"\">SYSTEM_VARIABLES_ADMIN<\/code> privileges<\/li>\n<li>MySQL 8.0+ or MariaDB 10.6+ (commands vary slightly for older versions \u2014 noted where relevant)<\/li>\n<li>Write permissions to the directory where the slow query log will be stored<\/li>\n<li>Root or sudo access if you&#8217;re editing <code class=\"\" data-line=\"\">my.cnf<\/code> \/ <code class=\"\" data-line=\"\">my.ini<\/code><\/li>\n<li>On cPanel servers: WHM root access if you want changes to persist across MySQL upgrades<\/li>\n<\/ul>\n<h2>Step-by-Step Instructions<\/h2>\n<h3>Method 1: Enable via my.cnf (Persistent \u2014 Survives Restarts)<\/h3>\n<p>This is the approach I&#8217;d recommend for production servers. Changes in the config file survive MySQL restarts and server reboots. The live SQL method is faster but resets on restart.<\/p>\n<ol>\n<li>\n    <strong>Find your MySQL config file.<\/strong> On most Linux servers it&#8217;s <code class=\"\" data-line=\"\">\/etc\/my.cnf<\/code> or <code class=\"\" data-line=\"\">\/etc\/mysql\/my.cnf<\/code>. On cPanel servers it&#8217;s almost always <code class=\"\" data-line=\"\">\/etc\/my.cnf<\/code>.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-1\"><code class=\"\" data-line=\"\">mysql --help | grep -A1 &quot;Default options&quot;<\/code><\/pre>\n<\/div>\n<p>    This prints the config file search order so you know exactly which file MySQL is actually reading.\n  <\/li>\n<li>\n    <strong>Open the config file in a text editor.<\/strong><\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-2\"><code class=\"\" data-line=\"\">sudo nano \/etc\/my.cnf<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n    <strong>Add the following lines under the <code class=\"\" data-line=\"\">[mysqld]<\/code> section.<\/strong> If the section doesn&#8217;t exist, add it.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-3\"><code class=\"\" data-line=\"\">[mysqld]\nslow_query_log = 1\nslow_query_log_file = \/var\/log\/mysql\/mysql-slow.log\nlong_query_time = 2\nlog_queries_not_using_indexes = 1<\/code><\/pre>\n<\/div>\n<p>A few things worth understanding here:<\/p>\n<ul>\n<li><code class=\"\" data-line=\"\">long_query_time = 2<\/code> logs any query taking over 2 seconds. On a busy e-commerce site, you might drop this to <code class=\"\" data-line=\"\">0.5<\/code> or even <code class=\"\" data-line=\"\">0.1<\/code> temporarily to catch borderline slow queries.<\/li>\n<li><code class=\"\" data-line=\"\">log_queries_not_using_indexes<\/code> is optional but genuinely useful \u2014 it catches queries that do full table scans even if they finish quickly. This is a common cause of slowdowns that only appear at scale.<\/li>\n<\/ul>\n<p>\ud83d\udcdd Note: On MariaDB, <code class=\"\" data-line=\"\">log_queries_not_using_indexes<\/code> can flood the log on tables with no indexes at all (like temp tables). Disable it if the log grows too fast.<\/p>\n<\/li>\n<li>\n    <strong>Create the log directory and set correct permissions.<\/strong> MySQL won&#8217;t create the directory for you, and it&#8217;ll silently fail to log if the path doesn&#8217;t exist or isn&#8217;t writable.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-4\"><code class=\"\" data-line=\"\">sudo mkdir -p \/var\/log\/mysql\nsudo chown mysql:mysql \/var\/log\/mysql\nsudo touch \/var\/log\/mysql\/mysql-slow.log\nsudo chown mysql:mysql \/var\/log\/mysql\/mysql-slow.log<\/code><\/pre>\n<\/div>\n<p>\u26a0 Warning: If you skip the <code class=\"\" data-line=\"\">chown<\/code> step, MySQL will start fine but the log file will stay empty. This trips up a lot of people.<\/p>\n<\/li>\n<li>\n    <strong>Restart MySQL to apply the changes.<\/strong><\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-5\"><code class=\"\" data-line=\"\"># systemd (most modern distros)\nsudo systemctl restart mysql\n\n# or on older CentOS\/cPanel systems\nsudo service mysql restart<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n    <strong>Confirm the log is enabled.<\/strong><\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-6\"><code class=\"\" data-line=\"\">SHOW VARIABLES LIKE &#039;slow_query%&#039;;\nSHOW VARIABLES LIKE &#039;long_query_time&#039;;<\/code><\/pre>\n<\/div>\n<p>    You should see <code class=\"\" data-line=\"\">slow_query_log<\/code> set to <code class=\"\" data-line=\"\">ON<\/code> and the file path you configured.\n  <\/li>\n<\/ol>\n<h3>Method 2: Enable Live via SQL (No Restart Required)<\/h3>\n<p>Use this when you need to start logging immediately without a restart \u2014 for example, on a production server where restarting MySQL would drop active connections.<\/p>\n<ol>\n<li>\n    <strong>Log in to MySQL as root or a privileged user.<\/strong><\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-7\"><code class=\"\" data-line=\"\">mysql -u root -p<\/code><\/pre>\n<\/div>\n<\/li>\n<li>\n    <strong>Run the following SQL commands.<\/strong><\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-8\"><code class=\"\" data-line=\"\">SET GLOBAL slow_query_log = &#039;ON&#039;;\nSET GLOBAL slow_query_log_file = &#039;\/var\/log\/mysql\/mysql-slow.log&#039;;\nSET GLOBAL long_query_time = 2;\nSET GLOBAL log_queries_not_using_indexes = 1;<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd Note: These settings are active immediately but reset to whatever&#8217;s in <code class=\"\" data-line=\"\">my.cnf<\/code> after the next MySQL restart. Always update the config file too if you want this to stick.<\/p>\n<\/li>\n<\/ol>\n<h3>Reading the Slow Query Log<\/h3>\n<p>Raw log entries look messy. The <code class=\"\" data-line=\"\">mysqldumpslow<\/code> tool groups similar queries together and sorts by total time, which is what you actually want.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-9\"><code class=\"\" data-line=\"\"># Top 10 slowest queries by total execution time\nmysqldumpslow -s t -t 10 \/var\/log\/mysql\/mysql-slow.log\n\n# Top 10 queries by average execution time\nmysqldumpslow -s at -t 10 \/var\/log\/mysql\/mysql-slow.log\n\n# Live tail of the log file\ntail -f \/var\/log\/mysql\/mysql-slow.log<\/code><\/pre>\n<\/div>\n<p>If you want a full breakdown with execution plans, copy a slow query from the log and run <code class=\"\" data-line=\"\">EXPLAIN<\/code> against it in MySQL:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-10\"><code class=\"\" data-line=\"\">EXPLAIN SELECT * FROM wp_posts WHERE post_status = &#039;publish&#039; AND post_type = &#039;post&#039;;<\/code><\/pre>\n<\/div>\n<p>The output tells you whether MySQL is using an index or doing a full table scan. A <code class=\"\" data-line=\"\">type<\/code> value of <code class=\"\" data-line=\"\">ALL<\/code> in the EXPLAIN output means a full table scan \u2014 almost always something worth fixing.<\/p>\n<h3>Disabling the Log When You&#8217;re Done<\/h3>\n<p>Don&#8217;t leave the slow query log running indefinitely on high-traffic servers. On a busy database server, the log file can grow to several gigabytes per day. Once you&#8217;ve identified the problem queries, turn it off.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-11\"><code class=\"\" data-line=\"\">-- Disable without restarting\nSET GLOBAL slow_query_log = &#039;OFF&#039;;<\/code><\/pre>\n<\/div>\n<p>Or edit <code class=\"\" data-line=\"\">my.cnf<\/code> and set <code class=\"\" data-line=\"\">slow_query_log = 0<\/code>, then restart MySQL.<\/p>\n<h2>Common Issues &amp; Troubleshooting<\/h2>\n<h3>Log file exists but stays empty<\/h3>\n<p>Almost always a permissions problem. MySQL is running as the <code class=\"\" data-line=\"\">mysql<\/code> system user and can&#8217;t write to the log path. Verify ownership:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-12\"><code class=\"\" data-line=\"\">ls -la \/var\/log\/mysql\/mysql-slow.log<\/code><\/pre>\n<\/div>\n<p>The file should be owned by <code class=\"\" data-line=\"\">mysql:mysql<\/code>. Fix it with <code class=\"\" data-line=\"\">sudo chown mysql:mysql \/var\/log\/mysql\/mysql-slow.log<\/code> and check the MySQL error log (<code class=\"\" data-line=\"\">\/var\/log\/mysql\/error.log<\/code>) for related messages.<\/p>\n<h3>MySQL fails to start after editing my.cnf<\/h3>\n<p>A typo in <code class=\"\" data-line=\"\">my.cnf<\/code> will prevent MySQL from starting. Check the exact error:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-13\"><code class=\"\" data-line=\"\">sudo journalctl -u mysql -n 50 --no-pager<\/code><\/pre>\n<\/div>\n<p>The most common mistake is adding slow query log directives outside the <code class=\"\" data-line=\"\">[mysqld]<\/code> section, or using incorrect variable names. MySQL 8.0 renamed some variables from MySQL 5.7 \u2014 for example, <code class=\"\" data-line=\"\">log_slow_queries<\/code> no longer exists; it&#8217;s <code class=\"\" data-line=\"\">slow_query_log<\/code>.<\/p>\n<h3>SET GLOBAL returns &#8220;Access denied&#8221;<\/h3>\n<p>Your MySQL user doesn&#8217;t have <code class=\"\" data-line=\"\">SYSTEM_VARIABLES_ADMIN<\/code> (MySQL 8.0) or <code class=\"\" data-line=\"\">SUPER<\/code> (MySQL 5.7 \/ MariaDB) privilege. Log in as root or grant the required privilege. On cPanel servers, you can find the root MySQL password in WHM under <strong>SQL Services &gt; MySQL Root Password<\/strong>.<\/p>\n<h3>long_query_time set to 2 but nothing is being logged<\/h3>\n<p>Check whether any queries are actually exceeding the threshold. Run a deliberate slow query to test:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-14\"><code class=\"\" data-line=\"\">SELECT SLEEP(3);<\/code><\/pre>\n<\/div>\n<p>If that appears in the log, your setup is correct and your queries are simply running under 2 seconds. Try lowering <code class=\"\" data-line=\"\">long_query_time<\/code> to <code class=\"\" data-line=\"\">0.5<\/code> temporarily to cast a wider net. In my experience, WordPress sites with poorly written plugins often have dozens of queries in the 0.5-1.5 second range that never get caught at the default threshold.<\/p>\n<h3>Log file is growing too fast<\/h3>\n<p>Either <code class=\"\" data-line=\"\">log_queries_not_using_indexes<\/code> is catching a lot of internal queries, or your <code class=\"\" data-line=\"\">long_query_time<\/code> is set too low. Disable <code class=\"\" data-line=\"\">log_queries_not_using_indexes<\/code> first and see if that helps. You can also rotate the log without restarting MySQL:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-15\"><code class=\"\" data-line=\"\">FLUSH SLOW LOGS;<\/code><\/pre>\n<\/div>\n<p>This closes and reopens the log file \u2014 useful if you&#8217;re managing log rotation with <code class=\"\" data-line=\"\">logrotate<\/code>.<\/p>\n<h2>FAQ<\/h2>\n<div class=\"ht-faq-section\">\n<h2>Frequently Asked Questions<\/h2>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Does enabling the MySQL slow query log slow down my database?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>There&#8217;s a small overhead \u2014 typically under 5% on most workloads \u2014 because MySQL has to write to disk for each logged query. For short debugging sessions this is negligible. On very high-traffic servers processing thousands of queries per second, I&#8217;d keep the session short and use a higher long_query_time threshold (2-5 seconds) to reduce log volume.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Where is the MySQL slow query log stored by default?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>MySQL doesn&#8217;t enable the slow query log by default, so there&#8217;s no default path until you configure one. Common paths on Linux are \/var\/log\/mysql\/mysql-slow.log or \/var\/lib\/mysql\/hostname-slow.log. Run SHOW VARIABLES LIKE &#8216;slow_query_log_file&#8217;; in MySQL to see the currently configured path.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Can I enable the slow query log in cPanel without SSH?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Not directly from the cPanel interface. You&#8217;ll need WHM root access to edit \/etc\/my.cnf, or SSH access to run SET GLOBAL commands. If you&#8217;re on a shared hosting plan without SSH, contact your host \u2014 though in practice, slow query logging is really a tool for VPS and dedicated server users who have full MySQL access.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">What&#039;s the difference between slow_query_log and general_log in MySQL?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>The general log records every single query MySQL processes, regardless of how fast it runs. It&#8217;s useful for debugging application behavior but generates enormous log files on any real workload. The slow query log only captures queries exceeding your long_query_time threshold, making it the practical choice for performance debugging.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How do I find the worst-performing queries once logging is enabled?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Use mysqldumpslow to parse the log \u2014 run mysqldumpslow -s t -t 10 \/path\/to\/mysql-slow.log to see the top 10 queries by total execution time. Once you&#8217;ve identified a problem query, run EXPLAIN against it in MySQL to see whether it&#8217;s missing an index. That EXPLAIN output is usually where the actual fix starts.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If your site is slow and you&#8217;re not sure why, the MySQL slow query log is the first place to look. It records every query that takes longer than a set threshold \u2014 giving you the exact SQL statements that are dragging things down.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[59],"tags":[600,287,602,599,598,604,603,601],"class_list":["post-218","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-database-debugging","tag-mariadb","tag-mysql-optimization","tag-mysql-performance","tag-mysql-slow-query","tag-mysql-slow-query-log","tag-query-tuning","tag-slow-query-log"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Enable MySQL Slow Query Log (and Actually Use It)<\/title>\n<meta name=\"description\" content=\"Learn how to enable the MySQL slow query log to identify and fix performance bottlenecks. Step-by-step guide for cPanel, VPS, and dedicated servers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Enable MySQL Slow Query Log (and Actually Use It)\" \/>\n<meta property=\"og:description\" content=\"Learn how to enable the MySQL slow query log to identify and fix performance bottlenecks. Step-by-step guide for cPanel, VPS, and dedicated servers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/\" \/>\n<meta property=\"og:site_name\" content=\"Host And Tech knowledge base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/stshostandtech\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-03T06:14:45+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:site\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\"},\"headline\":\"How to Enable MySQL Slow Query Log (and Actually Use It)\",\"datePublished\":\"2026-06-03T06:14:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/\"},\"wordCount\":1342,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"keywords\":[\"database debugging\",\"mariadb\",\"mysql optimization\",\"mysql performance\",\"mysql slow query\",\"MySQL slow query log\",\"query tuning\",\"slow query log\"],\"articleSection\":[\"MySQL &amp; MariaDB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/\",\"name\":\"How to Enable MySQL Slow Query Log (and Actually Use It)\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\"},\"datePublished\":\"2026-06-03T06:14:45+00:00\",\"description\":\"Learn how to enable the MySQL slow query log to identify and fix performance bottlenecks. Step-by-step guide for cPanel, VPS, and dedicated servers.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/how-to-enable-mysql-slow-query-log\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Enable MySQL Slow Query Log (and Actually Use It)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"name\":\"Host And Tech knowledge base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\",\"name\":\"Host And Tech knowledge base\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"contentUrl\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"width\":1134,\"height\":395,\"caption\":\"Host And Tech knowledge base\"},\"image\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/stshostandtech\",\"https:\\\/\\\/x.com\\\/stshostandtech\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/hostandtech.com\\\/kb\"],\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/author\\\/admin_fjj7qydm\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Enable MySQL Slow Query Log (and Actually Use It)","description":"Learn how to enable the MySQL slow query log to identify and fix performance bottlenecks. Step-by-step guide for cPanel, VPS, and dedicated servers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/","og_locale":"en_US","og_type":"article","og_title":"How to Enable MySQL Slow Query Log (and Actually Use It)","og_description":"Learn how to enable the MySQL slow query log to identify and fix performance bottlenecks. Step-by-step guide for cPanel, VPS, and dedicated servers.","og_url":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/","og_site_name":"Host And Tech knowledge base","article_publisher":"https:\/\/www.facebook.com\/stshostandtech","article_published_time":"2026-06-03T06:14:45+00:00","author":"admin","twitter_card":"summary_large_image","twitter_creator":"@stshostandtech","twitter_site":"@stshostandtech","twitter_misc":{"Written by":"admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/#article","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/"},"author":{"name":"admin","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee"},"headline":"How to Enable MySQL Slow Query Log (and Actually Use It)","datePublished":"2026-06-03T06:14:45+00:00","mainEntityOfPage":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/"},"wordCount":1342,"commentCount":0,"publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"keywords":["database debugging","mariadb","mysql optimization","mysql performance","mysql slow query","MySQL slow query log","query tuning","slow query log"],"articleSection":["MySQL &amp; MariaDB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/","url":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/","name":"How to Enable MySQL Slow Query Log (and Actually Use It)","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/#website"},"datePublished":"2026-06-03T06:14:45+00:00","description":"Learn how to enable the MySQL slow query log to identify and fix performance bottlenecks. Step-by-step guide for cPanel, VPS, and dedicated servers.","breadcrumb":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hostandtech.com\/kb\/mysql\/how-to-enable-mysql-slow-query-log\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostandtech.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to Enable MySQL Slow Query Log (and Actually Use It)"}]},{"@type":"WebSite","@id":"https:\/\/hostandtech.com\/kb\/#website","url":"https:\/\/hostandtech.com\/kb\/","name":"Host And Tech knowledge base","description":"","publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostandtech.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostandtech.com\/kb\/#organization","name":"Host And Tech knowledge base","url":"https:\/\/hostandtech.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","contentUrl":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","width":1134,"height":395,"caption":"Host And Tech knowledge base"},"image":{"@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/stshostandtech","https:\/\/x.com\/stshostandtech"]},{"@type":"Person","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/hostandtech.com\/kb"],"url":"https:\/\/hostandtech.com\/kb\/author\/admin_fjj7qydm\/"}]}},"_links":{"self":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":0,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"wp:attachment":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}