Changing default storage engine in MySQL

It took me a while to find the answer to this, so I thought I'd share it to avoid anybody else wasting time with this. I needed to change the default storage engine so Django would use innoDB rather than MyISAM. Otherwise, it seemed to take the default.

You first need to locate the MySQL config file named my.cnf. On CentOS 5.2 it is located at /etc/my.cnf but this will probably vary across platforms.

Then in that file find the [mysqld] and add add the following line below it as shown below.

[mysqld]
default-storage-engine = innodb

Finally, make sure you restart MySQL.

service mysqld restart

It's pretty easy when you know how, and you'll now had transactional tables by default.

Alterantivaley though, you could use a much better database.


Thanks for reading. You should follow me on Twitter.

Do you have any feedback or comments? The best place for discussion is on Reddit or Hacker News. Otherwise, email me.