Mysql – Set InnoDB as default engine and set a default collation

configurationinnodbMySQLmysql-5.7

What should I do to set InnoDB as the default database engine?
And is possible to set a default collation when I create a schema and tables (e.g. utf8mb4)?

I don't want to have to choose these options every time I create a new database.

I am using MySQL 5.7.

Best Answer

You can set default-storage-engine=InnoDB (Set the default storage engine for tables) and you can even force your customers to use InnoDB with enforce_storage_engine=InnoDB (Force the use of a particular storage engine for new tables). enforce_storage_engine is a MariaDB only feature.

Default character set and collation you can set in my.cnf

[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci

The other options like default storage engine need also be in my.cnf to be permanent.

When you don't specify storage engine, collation and character set, MySQL chooses defaults set by you.