Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set default storage engine used by MySQL?

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?

like image 553
memilanuk Avatar asked Jun 16 '10 03:06

memilanuk


People also ask

What is default storage engine in MySQL?

InnoDB : The default storage engine in MySQL 8.0. InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.

Which is the default storage engine in MySQL 12?

MySQL: InnoDB Storage Engine InnoDB is a storage engine for MySQL that balances high reliability and high performance. As of MySQL 5.5 and later, it is the default storage engine.

How do I change the default storage engine in phpMyAdmin?

Access phpMyAdmin and select your database. Then click on SQL, place the following query and click on Go: ALTER TABLE my_table ENGINE = InnoDB; If the query is executed properly, the database engine of the table will be changed to InnoDB.


1 Answers

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; 
like image 134
Daniel Vassallo Avatar answered Oct 14 '22 12:10

Daniel Vassallo