CA BD NY
  • Categories

  • Recent Posts

  • User Services

  • RSS Apache Hacker

  • RSS CentOS Hacker

  • RSS miniCTO

  • Spam Blocked

  •  Subscribe in a reader

    Add to Google Reader or Homepage

    Enter your email address:

  • Our Tweets

  • Automatically Loading MySQL Memory Tables on MySQL Startup or Reboot

    Published October 28th, 2008

    Problem Statement:

    If you use MySQL memory tables a lot to speed up frequently used but rarely changed data, you are faced with a problem of loading the memory tables manually whenever you start or reboot your MySQL server. You need an automated of loading the memory tables; here we will show you how.

    Solution

    To load MySQL memory tables with data from existing physical tables, you can do the following:

    1. Edit your /etc/my.cnf file and add the following line under the [mysqld] section:
    2. init_file=/etc/my.memory.tables.init.sql

    3. Now create a text file called /etc/my.memory.tables.init.sql file to to have a statement such as the following for each memory table to load from a physical table:
    4. INSERT into db_name.memory_table SELECT * FROM db_name.physical_table;

    5. Restart your MySQL server
    6. You should check of your memory tables and notice that they have data from physical tables

    Make sure your SQL statements are prefixed with database name as we show in the above-mentioned sample query; this will make sure the statements load data from the correct database.

    If you found this post useful, please subscribe to our RSS feed. Thanks for visiting!

    Get a Trackback link

    1 Comments

    1. liz on November 30, 2008

      Hello Kabir,

      I have gone through this and found the following lines to be confusing. Please revise.

      “You need an automated of loading the memory tables;”

      “Now create a text file called /etc/my.memory.tables.init.sql file to to have a statement”

      “this will make sure the statements load data from the correct database.”

      Thanks.

    Leave a comment

    Comment Policy: First time comments are moderated. Please be patient.