Changing query_cache_type in MySQL

query_cache_type – this parameter enables or disables the operation of MySQL Query Cache.

Connect to the MySQL server and see the current value:

mysql -u root -p
SHOW VARIABLES LIKE "query_cache_type";
SHOW VARIABLES LIKE "query_cache_%";

There may be three values:
0 (OFF) query caching is disabled.
1 (ON) all queries except SELECT SQL_NO_CACHE are cached.
2 (DEMAND) only SELECT SQL_CACHE queries are cached.

If you need to change the value, for example, disable caching without restarting the MySQL server, then execute:

set global query_cache_type=0;

So that the value is not reset after restarting the MySQL server, open the configuration file in a text editor:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

And we specify:

query_cache_type=0

See also my article:
table_open_cache

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a comment

Leave a Reply