the goal is simple, but rather unusual. I wrote a database auto-repair script (as one of the tables keeps crashing from time to time, probably due to very large amounts being inserted and deleted constantly), and I want to test it. The problem is, that I need to crash a table on purpose, and I have no idea how. Any suggestions?
The most common cause of crashes in MySQL is that it stopped or failed to start due to insufficient memory. To check this, you will need to review the MySQL error log after a crash. First, attempt to start the MySQL server by typing: sudo systemctl start mysql.
In MyIsam, run OPTIMIZE TABLE
and kill it while it runs. The table will be marked as crashed.
You can certainly make a MyISAM table look crashed by truncating the .MYI file to 4k (Assuming it was bigger than 4k). Then do a FLUSH TABLE, followed by a query which needs to use an index.
If the tables are crashing spontaneously, then either
MyISAM tables should not crash spontaneously, but you can expect them to crash following an unclean shutdown. Unclean shutdowns should not happen very often, if they are, it is an operational problem. Ask your operations engineers what's going on. It is normally clear what's happened from reviewing the mysql server error log.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With