In this tip we will see how to disable the MySQL query cache option under a system running Ubuntu (12.04/11.10 or older). You should know that the MySQL query cache being enabled will speed up database query performance. Anyway, if you want to disable it, you can follow these instructions:

Temporary Solution

To disable the MySQL query cache for the current running session you need to do the following, but keep in mind that it will be enabled automatically on your next restart:

- Open the terminal and sign in to your MySQL server with this command (use the password assigned during the installation of the MySQL server):

mysql -u root -p

Note: If you haven't assigned a MySQL root password, you can set one as described here.

 - After starting your MySQL server, run this command to disable MySQL query cache:

SET GLOBAL query_cache_size = 0;

- If successful, you will get these outputs:

mysql> SET GLOBAL query_cache_size = 0;
Query OK, 0 rows affected (0.00 sec)

- Exit now the MySQL server with this command:


Permanent Solution

To disable MySQL query cache permanently, follow these instructions:

- Open the terminal and edit the MySQL conf file with this command:

gksu gedit /etc/mysql/my.cnf

- Press Ctrl+F and search this line:


- Set now its value to zero (0):

- Press Ctrl+Q and save your file.

That's it!

Post a Comment