How can I set default storage engine used by MySQL?

MysqlDatabaseInnodb

Mysql Problem Overview


I've been working on writing SQL to create a MySQL database with several default options, including character set and collation. Is it possible to set the default storage engine for tables in this database to InnoDB?

I've been looking through the MySQL 5.1 manual and I've found the statement ENGINE=innodb which would be appended to a CREATE TABLE statement, but I haven't found anything related to a CREATE DATABASE statement.

Is there a normal way to do this as part of the database creation, or does it need to be specified on a table-by-table basis?

Mysql Solutions


Solution 1 - Mysql

Quoting the Reference Manual (Setting the Storage Engine):

> If you omit the ENGINE option, the default storage engine is used. Normally, this is MyISAM, but you can change it by using the --default-storage-engine server startup option, or by setting the default-storage-engine option in the my.cnf configuration file.

The default-storage-engine option must be part of the mysqld section in my.cnf;

[mysqld]
default-storage-engine = innodb

You may also want to change the default storage engine just for the current session. You can do this by setting the storage_engine variable:

SET storage_engine=INNODB;

Solution 2 - Mysql

you need to specify the default storage engine when starting mysqld. for example:

mysqld --default-storage-engine=InnoDB

http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmemilanukView Question on Stackoverflow
Solution 1 - MysqlDaniel VassalloView Answer on Stackoverflow
Solution 2 - MysqlsmlView Answer on Stackoverflow