I have a VPS running CentOs 6.5, PHP-FPM, Mysql database and Nginx server.
I installed and used mysql by default, which I can see now that it is using InnoDB as the default engine. So, after realizing that my VPS was running out of its 512 RAM usage, I started to optimize Nginx and PHP-FPM. And now, I have learned that InnoDB uses more memory (at-least while reading) than MyISAM engine, so I am trying to change the default engine of mysql to use MyISAM.
The problem is that since I am new at this, I am worried that amidst the process of changing I may corrupt the database, as I barely had done this before.
So, the first thing I have done, is to save the entire Mysql data just to be on the safe side
cp –Rp /var/lib/mysql/*.* /backup
Now according to this answer the easiest way to change engines is
ALTER TABLE table_name ENGINE = MyISAM;
So, now my question is, is it safe, and if it that's all it takes to change directly the engine for my databases, which in turn will result in memory optimization ? Or is there another way.
Mostly InnoDB is better choice than a MyISAM. You can read a bit more about it here. Everything depends on your tables. If you want to read from them (with not many inserts/updates/deletes) then you can think about MyISAM. In other cases if there is many write operation i will recommend you to stay on InnoDB.
Going back to your question: ALTER TABLE table_name ENGINE = MyISAM; is safe. It can take a while (on big tables) but your data should not been broken after this operation. If there will be any problem, MySQL will inform you about it and conversion will be not performed. In worst case you have backup and you can restore it in any time.
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