Search code examples
mysqlmemory-table

How to run a MySQL query on every service start?


I need to run a query to populate a memory table on every MySQL start.

Is there any way to do this?


Solution

  • MySQL is able to read statements from init_file on startup.

    You'd have to place the following in my.ini or my.cnf (depending on the OS) file

    [mysqld] 
    init-file="/path/to/your/query/populate_memory_table.sql"