{"id":4785,"date":"2025-01-05T03:23:43","date_gmt":"2025-01-05T08:23:43","guid":{"rendered":"https:\/\/underhost.com\/blog\/?p=4785"},"modified":"2026-10-23T08:54:00","modified_gmt":"2026-10-23T12:54:00","slug":"optimizing-database-performance-in-cpanel-for-faster-sites","status":"publish","type":"post","link":"https:\/\/underhost.com\/blog\/optimizing-database-performance-in-cpanel-for-faster-sites\/","title":{"rendered":"Speed Up MySQL and MariaDB on cPanel: What Users and Server Admins Can Do"},"content":{"rendered":"<div class=\"uh-blog-hero\" style=\"margin:0 0 40px;text-align:center;padding:48px 24px;border-radius:20px;background:linear-gradient(135deg,#0D1F3C 0%,#125A8A 58%,#176EA5 100%);color:#ffffff;box-shadow:0 20px 40px -15px rgba(13,31,60,0.28);position:relative;overflow:hidden;\">\n<div style=\"display:inline-flex;align-items:center;gap:8px;padding:7px 14px;margin-bottom:16px;border:1px solid rgba(0,212,255,0.32);border-radius:999px;color:#DFF8FF;font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;background:rgba(0,212,255,0.10);\"><i class=\"fas fa-sliders-h\" style=\"color:#00D4FF;\"><\/i> Control Panels<\/div>\n<h1 style=\"color:#ffffff;font-size:clamp(32px,5vw,46px);line-height:1.12;margin:0 0 14px;font-weight:800;\">Speed Up MySQL and MariaDB on cPanel: What Users and Server Admins Can Do<\/h1>\n<p style=\"font-size:18px;color:#EAF6FF;max-width:800px;margin:0 auto;line-height:1.7;\">Boost your website&#8217;s speed and user experience by optimizing database performance in cPanel. Learn expert tips on tuning MySQL 8 and MariaDB settings to reduce load times and enhance efficiency.<\/p>\n<\/div>\n<div style=\"background:#FFF7ED;border:1px solid #FDBA74;border-radius:16px;padding:20px 22px;margin:24px 0;\">\n<h3 style=\"margin:0 0 10px;color:#9A3412;font-size:20px;\"><i class=\"fas fa-exclamation-triangle\" style=\"color:#F97316;\"><\/i> Test first:<\/h3>\n<p style=\"margin:0;color:#7C2D12;line-height:1.7;\">The settings below are examples. The right values depend on your server&#8217;s memory and workload, so change one thing at a time and test on a copy of the site.<\/p>\n<\/div>\n<div class=\"uh-blog-excerpt\" style=\"border-left:4px solid #00D4FF;padding:18px 20px;margin:0 0 34px;background:#F8FAFC;color:#1F2937;border-radius:0 14px 14px 0;box-shadow:0 8px 28px rgba(13,31,60,0.08);line-height:1.75;\"><strong style=\"color:#0D1F3C;\">Short answer:<\/strong> Most slow databases on hosting accounts are caused by a few slow queries, missing indexes, bloated tables such as WordPress autoloaded options, and no caching. As a cPanel user, clean up the database, add an object cache such as Redis, and keep plugins lean. As a server administrator, size <code>innodb_buffer_pool_size<\/code> for your RAM, turn on the slow query log, and fix the queries it shows. MySQL 8 no longer has a query cache, so do not try to enable one.<\/div>\n<div class=\"uh-post-content\" style=\"color:#1F2937;font-size:16px;line-height:1.75;\">\n<h2 id=\"find-out-whether-the-database-is-the-problem\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-exclamation-triangle\" style=\"color:#00D4FF;\"><\/i> Find out whether the database is the problem<\/h2>\n<p style=\"margin:0 0 18px;\">Before tuning anything, confirm the database is what makes pages slow. A query monitor plugin (on WordPress, Query Monitor) shows how many queries each page runs and which are slow. Hundreds of queries per page, or single queries that take more than a second, point to the database.<\/p>\n<h2 id=\"for-cpanel-users-no-root-access\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-angle-double-right\" style=\"color:#00D4FF;\"><\/i> For cPanel users (no root access)<\/h2>\n<h3 style=\"color:#0D1F3C;font-size:21px;line-height:1.3;margin:26px 0 10px;\">Clean up the data<\/h3>\n<ul style=\"margin:0 0 24px;padding-left:22px;\">\n<li style=\"margin:0 0 8px;\">Delete old post revisions, spam comments, expired transients and leftover tables from removed plugins.<\/li>\n<li style=\"margin:0 0 8px;\">On WordPress, check the size of autoloaded options. Large autoloaded data is loaded on every page.<\/li>\n<li style=\"margin:0 0 8px;\">Use phpMyAdmin&#8217;s <strong>Optimize table<\/strong> after deleting a lot of data, to reclaim space. It is not needed as routine maintenance on InnoDB tables.<\/li>\n<\/ul>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>-- WordPress: size of autoloaded options (run in phpMyAdmin, SQL tab)\nSELECT ROUND(SUM(LENGTH(option_value))\/1024) AS autoload_kb\nFROM wp_options WHERE autoload IN ('yes','on');<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Replace <code>wp_<\/code> with your table prefix. More than about 1 MB is worth investigating.<\/p>\n<h3 style=\"color:#0D1F3C;font-size:21px;line-height:1.3;margin:26px 0 10px;\">Add caching<\/h3>\n<p style=\"margin:0 0 18px;\">Page caching stops most visitors from triggering database queries at all. An object cache such as Redis keeps the results of repeated queries in memory. Our guide to <a href=\"https:\/\/underhost.com\/blog\/how-cpanel-redis-manager-brings-faster-application-performance-to-your-server\/\">Redis Manager for cPanel<\/a> shows how to add one.<\/p>\n<h3 style=\"color:#0D1F3C;font-size:21px;line-height:1.3;margin:26px 0 10px;\">Fix slow plugins and queries<\/h3>\n<ul style=\"margin:0 0 24px;padding-left:22px;\">\n<li style=\"margin:0 0 8px;\">Remove plugins that run heavy queries on every page, such as some statistics and related-post plugins.<\/li>\n<li style=\"margin:0 0 8px;\">Ask the developer of a custom application to add indexes to columns used in WHERE and JOIN clauses.<\/li>\n<li style=\"margin:0 0 8px;\">Use the newest PHP version your site supports; it also speeds up the code that talks to the database.<\/li>\n<\/ul>\n<h2 id=\"for-server-administrators-root-access\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-server\" style=\"color:#00D4FF;\"><\/i> For server administrators (root access)<\/h2>\n<h3 style=\"color:#0D1F3C;font-size:21px;line-height:1.3;margin:26px 0 10px;\">Size the InnoDB buffer pool<\/h3>\n<p style=\"margin:0 0 18px;\">The buffer pool keeps table data and indexes in memory. On a server that also runs a web server and PHP, a common starting point is a quarter to a half of the RAM, and no more than the total size of your databases. Set it in <code>\/etc\/my.cnf<\/code>:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>[mysqld]\ninnodb_buffer_pool_size = 2G<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Restart the service with <code>\/scripts\/restartsrv_mysql<\/code>, then watch memory use. If the server starts to swap, lower the value.<\/p>\n<h3 style=\"color:#0D1F3C;font-size:21px;line-height:1.3;margin:26px 0 10px;\">Turn on the slow query log<\/h3>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>[mysqld]\nslow_query_log = 1\nslow_query_log_file = \/var\/lib\/mysql\/slow.log\nlong_query_time = 1<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">After a day, summarise the log to find the worst queries:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>mysqldumpslow -s t -t 10 \/var\/lib\/mysql\/slow.log<\/code><\/pre>\n<h3 style=\"color:#0D1F3C;font-size:21px;line-height:1.3;margin:26px 0 10px;\">Check other common settings<\/h3>\n<div style=\"overflow-x:auto;margin:26px 0;border:1px solid #E5E7EB;border-radius:14px;-webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%;border-collapse:collapse;background:#ffffff;color:#1F2937;font-size:15px;line-height:1.55;margin:0;\">\n<thead>\n<tr style=\"background:#0D1F3C;color:#fff;\">\n<th style=\"padding:14px;text-align:left;\">Setting<\/th>\n<th style=\"padding:14px;text-align:left;\">What to check<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">max_connections<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Raise it only if you see &#8220;Too many connections&#8221; errors; more connections use more memory.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">tmp_table_size \/ max_heap_table_size<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Larger values reduce temporary tables written to disk for complex queries.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Query cache<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Removed in MySQL 8 and disabled by default in current MariaDB. Use Redis or page caching instead.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"margin:0 0 18px;\">MySQLTuner is a free script that reviews a running server and suggests changes. Treat its output as hints and change one setting at a time.<\/p>\n<h3 style=\"color:#0D1F3C;font-size:21px;line-height:1.3;margin:26px 0 10px;\">Keep the database server current<\/h3>\n<p style=\"margin:0 0 18px;\">Newer MySQL and MariaDB versions are faster and still get security fixes. See our guide to <a href=\"https:\/\/underhost.com\/blog\/almalinux-9-with-cpanel-mysql-8-to-mariadb-10-11-guide\/\">choosing MariaDB or MySQL on cPanel<\/a>.<\/p>\n<h2 id=\"when-to-move-to-more-resources\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-book\" style=\"color:#00D4FF;\"><\/i> When to move to more resources<\/h2>\n<p style=\"margin:0 0 18px;\">If the database still struggles after cleanup, caching and tuning, the server is too small for the workload. A Cloud VPS gives the database its own memory and fast NVMe storage; very large stores may need a dedicated server.<\/p>\n<div aria-hidden=\"true\" class=\"uh-section-divider\" style=\"width:min(100% - 32px, 1080px);margin:44px auto;display:grid;grid-template-columns:1fr 32px 1fr;align-items:center;gap:18px;pointer-events:none;\"><span style=\"height:1px;background:linear-gradient(90deg,transparent,rgba(0,212,255,0.40),rgba(23,110,165,0.24),transparent);\"><\/span><img alt=\"\" decoding=\"async\" height=\"32\" loading=\"lazy\" src=\"https:\/\/cdn.underhost.com\/android-chrome-192x192.webp\" style=\"width:32px;height:32px;display:block;border-radius:8px;filter:drop-shadow(0 0 14px rgba(0,212,255,0.30));\" width=\"32\"\/><span style=\"height:1px;background:linear-gradient(90deg,transparent,rgba(23,110,165,0.24),rgba(0,212,255,0.40),transparent);\"><\/span><\/div>\n<\/div>\n<div class=\"uh-blog-cta\" style=\"background:linear-gradient(135deg,#0D1F3C 0%,#125A8A 58%,#176EA5 100%);color:#ffffff;padding:36px 24px;border-radius:20px;text-align:center;margin:44px 0;box-shadow:0 20px 40px -15px rgba(13,31,60,0.32);\">\n<h2 style=\"margin:0 0 12px;font-size:28px;line-height:1.25;color:#ffffff;\">Need help with this?<\/h2>\n<p style=\"font-size:17px;margin:0 auto 22px;color:#EAF6FF;max-width:720px;line-height:1.7;\">Database slowing your site down? Our team can tune MySQL or MariaDB and add caching on your server.<\/p>\n<p><a href=\"https:\/\/underhost.com\/server-management.php\" style=\"background:linear-gradient(90deg,#00D4FF,#0077FF);color:#ffffff;padding:13px 28px;border-radius:10px;text-decoration:none;font-weight:800;display:inline-block;margin:8px;\">See server management plans<\/a><a href=\"https:\/\/customerpanel.ca\/client\/\" style=\"background:transparent;color:#ffffff;padding:12px 28px;border-radius:10px;text-decoration:none;font-weight:800;display:inline-block;margin:8px;border:1px solid rgba(255,255,255,0.32);\">Contact @CustomerPanel<\/a><\/div>\n<div class=\"uh-faq-section\" id=\"faq\" style=\"margin:34px 0;scroll-margin-top:90px;\">\n<h2 style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:0 0 18px;border-bottom:2px solid rgba(0,212,255,0.22);padding-bottom:10px;\">Frequently asked questions<\/h2>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">How do I enable the query cache in MySQL 8?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">You cannot. MySQL 8 removed it. Use page caching and an object cache such as Redis instead.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Should I optimize tables every week?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">No. On InnoDB tables it is only useful after deleting a lot of data. Routine optimizing adds load for little gain.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">How much memory should the InnoDB buffer pool get?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">On a shared web and database server, start with a quarter to a half of the RAM, and not more than the size of your data.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Can I edit my.cnf on shared hosting?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">No. It is a server-wide file. On shared hosting, focus on cleanup, caching and lean plugins.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">How do I find slow queries?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Use a query monitoring plugin for your CMS, or ask your administrator to enable the slow query log.<\/p>\n<\/div>\n<\/div>\n<p><!-- uh-related-start --><\/p>\n<div style=\"background:#F4F8FC;border:1px solid #DCE7F3;border-radius:14px;padding:18px 22px;margin:32px 0 8px;\">\n<h2 style=\"margin:0 0 12px;font-size:22px;\">Related guides<\/h2>\n<ul style=\"margin:0;padding-left:20px;\">\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/how-cpanel-redis-manager-brings-faster-application-performance-to-your-server\/\">How cPanel Redis Manager Brings Faster Application Performance to Your Server<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/optimizing-php-performance-in-cloudlinux-with-php-selector-a-developers-guide\/\">Optimizing PHP Performance in CloudLinux with PHP Selector: A Developer&#8217;s Guide<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/optimizing-php-performance-in-cloudlinux-with-php-selector\/\">Optimizing PHP Performance in CloudLinux with PHP Selector<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/how-to-reset-wordpress-admin-password-via-ssh\/\">How to Reset a WordPress Admin Password (Email, WP-CLI or Database)<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/the-best-way-to-use-cloudflare-with-cpanel-whm-for-better-performance\/\">The Best Way to Use Cloudflare with cPanel &amp; WHM for Better Performance<\/a><\/li>\n<\/ul>\n<\/div>\n<p><!-- uh-related-end --><br \/>\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"How do I enable the query cache in MySQL 8?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"You cannot. MySQL 8 removed it. Use page caching and an object cache such as Redis instead.\"}}, {\"@type\": \"Question\", \"name\": \"Should I optimize tables every week?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. On InnoDB tables it is only useful after deleting a lot of data. Routine optimizing adds load for little gain.\"}}, {\"@type\": \"Question\", \"name\": \"How much memory should the InnoDB buffer pool get?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"On a shared web and database server, start with a quarter to a half of the RAM, and not more than the size of your data.\"}}, {\"@type\": \"Question\", \"name\": \"Can I edit my.cnf on shared hosting?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"No. It is a server-wide file. On shared hosting, focus on cleanup, caching and lean plugins.\"}}, {\"@type\": \"Question\", \"name\": \"How do I find slow queries?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Use a query monitoring plugin for your CMS, or ask your administrator to enable the slow query log.\"}}]}<\/script><\/p>\n<h2 id=\"sources\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-book\" style=\"color:#00D4FF;\"><\/i> Sources<\/h2>\n<ul style=\"margin:0 0 24px;padding-left:22px;\">\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/innodb-buffer-pool-resize.html\">MySQL 8.0 reference: InnoDB buffer pool configuration<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/slow-query-log.html\">MySQL 8.0 reference: the slow query log<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/mariadb.com\/kb\/en\/query-cache\/\">MariaDB knowledge base: query cache<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Boost your website&#8217;s speed and user experience by optimizing database performance in cPanel. Learn expert tips on tuning MySQL 8 and MariaDB settings to reduce load times and enhance efficiency.<\/p>\n","protected":false},"author":1,"featured_media":4786,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,202],"tags":[108,116],"class_list":["post-4785","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-control-panels","category-cpanel-whm","tag-tag-cpanel","tag-tag-wordpress"],"_links":{"self":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/4785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/comments?post=4785"}],"version-history":[{"count":8,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/4785\/revisions"}],"predecessor-version":[{"id":6926,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/4785\/revisions\/6926"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media\/4786"}],"wp:attachment":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media?parent=4785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/categories?post=4785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/tags?post=4785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}