Logo Background RSS

» cache

  • Enable caching in MySQL
    By on February 2nd, 2009 | 1 Comment1 Comment Comments

    Log into your mysql

    $ mysql -u root –p

    Output:

    Enter password:

    Welcome to the MySQL monitor. Commands end with ; or \g.

    Your MySQL connection id is 16 to server version: 4.1.15-Debian_1-log
    Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

    mysql>

    Now setup cache size 32Mb:
    mysql> SET GLOBAL query_cache_size = 33554432;    
    
    Query OK, 0 rows affected (0.00 sec)
    mysql> SHOW VARIABLES LIKE 'query_cache_size';

    Output:

    +——————+———-+

    | Variable_name | Value |

    +——————+———-+

    | query_cache_size | 16777216 |

    +——————+———-+

    You can setup them in /etc/my.cnf (Red Hat) or /etc/mysql/my.cnf (Debian) file:
    # vi /etc/my.cnf
    Append config directives as follows:

    query_cache_size = 33554432
    query_cache_type=1
    query_cache_limit=2096576