Changing default storage engine in MySQL

This took me a while to figure out so I thought I’d put it here for future reference! I needed to change it so that Django would use innoDB rather that MyISAM, it seemed to just take the default and I couldn’t find an override.

You need to locate the mySQL config file (helpfully named) my.cnf file. On Centos 5.2 it is located at /etc/my.cnf

Then under the [mysqld] add the following line as shown below!

[mysqld]
default-storage_engine = innodb

Finally, restart mySQL;

$ service mysqld restart

It’s pretty easy to do when you know how and now you have transactional tables by default :)

3 Responses to “Changing default storage engine in MySQL”

  1. Nayan Hajratwala Says:

    Thanks Dougal - this was just the quick answer I needed. However, I believe it should be “default-storage-engine” instead of “default-storage_engine”. Note the underscore.

  2. Dougal Says:

    Interesting. I will check when I’m home but I’m almost 100% sure I’ve got default-storage_engine in my config.

    Did you do it your way and it worked? Maybe it can be either?

  3. Valle Says:

    Thank you very much for this post. I’ve been searching a long time for this. :-)

Leave a Reply