Changing table_open_cache in MySQL

table_open_cache – the number of cached open tables for all threads. Opening tables is a resource-intensive process, so it is recommended to keep a certain number of tables open in the cache.

Let’s see the current value (by default 400, minimum 1, maximum 524288):

mysql -u root -p
show variables like "table_open_cache";

If you need to change the value without stopping the MySQL server, then:

set global table_open_cache=8192;

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:

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