Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 253
stramin Avatar asked Nov 01 '25 17:11

stramin


1 Answers

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"
like image 87
Giorgos Myrianthous Avatar answered Nov 04 '25 10:11

Giorgos Myrianthous