Skip to content
Advertisement

Run SQL query on MySQL service startup

I have created HEAP (ram) table on mysql for faster query. But after mysql server restarted, the data in my Heap tables is not loaded.

My normal table name: products with id, product_name, status as myisam

id => integer and auto_increment, primary key

product_name => var_char and key(index)

status => boolean

Actual Query:

`Select id from products where product_name like "product_name"`

I want to increase speed, so i created table with same structure and with named products_ram as mysql HEAP table. I am using this code for fill:

insert p_shop.products_ram select * from p_shop.products;

But when restart mysql instance HEAP (ram) table data has gone.

I found a document about mysql memory storage : http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html

But i can’t find what i looking for.

I want to insert/copy my data from products table to products_ram table on mysql server initialization automatically.

Any help will be appreciated.

Edit: My Operating System : Windows Server 2008 R2 And Mysql : MySQL 5.5

Advertisement

Answer

The init_file server option lets you define arbitrary SQL statements to be executed on startup.


Edit: Changed the link as the resource has moved on the target site.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement