How to truncate MySQL table on boot,
but want make sure script execute after mysqld started
mysql -h localhost -u root -pPASSWORD DBNAME -e "truncate table tables"
thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Create a script startup.sql, store it in your data directory, make it readable to the server. The startup.sql script contains the statements you need, for example “TRUNCATE TABLE tables;”.
Add the following line to the [mysqld] section of your my.cnf file:
init-file=startup.sql
Stop and restart the server to test.
The relevant documentation can be found here: http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_init-file