Change Default Storage Engine in MySQL
Jan30
I like my default engine to be InnoDB because it’s fully transactional and supports foreign key references. However, the default engine in MySQL is MyISAM.
There are several ways to change the default storage engine:
- Add default-storage-engine = innodb to your /etc/mysql/my.cnf under mysqld server section
- The default storage engine can be specified at server startup with the –default-storage-engine option.
- For a running server, an administrator who has the SUPER privilege can change the default storage engine globally for all clients by setting the global storage_engine system variable:
SET GLOBAL storage_engine = innodb;
Setting the storage engine this way affects any client that connects after the statement executes. Clients that are connected at the time of statement execution are unaffected.
- Any client can change its own default storage engine by issuing either of these statements:
SET SESSION storage_engine = innodb; SET storage_engine = innodb;
If you change your default storage engine using Method 1, you can optimize the performance by adding few more instructions, as explained in this Stack Overflow post.
I use Method 1, and I added 3 lines to my /etc/mysql/my.cnf:
Under [mysqld] :
default-character-set = utf8 default-storageengine = innodb
… then I also added this line in InnoDB section:
innodb_buffer_pool_size = 512M