MySQL: Set Cache Size

How do I set query cache under MySQL running under UNIX / Linux / BSD or Windows operating systems?

MySQL has a great feature called “Query Cache”. It allows you to improve MySQL server performance. It is quite useful to speed up third party application and/or low load applications.


Enabling MySQL Query Cache

Edit MySQL config file such as /etc/my.cnf:
# vi /etc/my.cnf
Append /modify config directives as follows:

query_cache_size = 268435456

In above example the maximum size of individual query results that can be cached set to 1048576 using query_cache_limit system variable. Memory size in defined in Kb. The query_cache_size defines the amount of memory allocated for caching query results. The default value is 0, which disables the query cache. The allowable values are multiples of 1024; other values are rounded down to the nearest multiple. Once done restart mysql server. Please note that this is not distributed caching solution.

Distributed MySQL Caching Solution

Memcached is one of most popular distributed caching system. This software is highly recommend if you got busy website or mysql server. See how to install and configure Memcached caching under RHEL / CentOS /operating systems.

See also:

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.