HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

How to permanently enable query cache in MySQL?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
permanentlyenablequerymysqlcachehow

Problem

I want to know if there's a way to permanently set the size of my query cache and to make sure it's always enabled.
Right now, I'm just using the set global query_cache_size command to set the size, but when the database is restarted it goes away.

Solution

You can set this parameter in /etc/my.cnf on Red Hat or /etc/mysql/my.cnf on Debian (other systems have the my.cnf file in various locations):

# vi /etc/my.cnf


Append config directives as follows:

query_cache_size = 268435456
query_cache_type = 1
query_cache_limit = 1048576


Change the values as appropriate to your system!

Code Snippets

# vi /etc/my.cnf
query_cache_size = 268435456
query_cache_type = 1
query_cache_limit = 1048576

Context

StackExchange Database Administrators Q#50877, answer score: 6

Revisions (0)

No revisions yet.