Monday 7 November 2011

Specify InnoDb as default table type in JDBC

One of the recurrent gotchas with MySQL is that the default table type is MyISAM, whereas you almost definitely need InnoDB, if you want transactions, indexing or anything else that would make MySQL a useful database.

Set default table type for all databases

In /etc/mysql/my.cnf add: [mysqld]
default-storage-engine=InnoDB
But this requires that you have root access to the server and that you want all tables to use InnoDB.

Specify default on JDBC url

database.url=jdbc\:mysql\://localhost\:3306/chassis_studies?autoReconnect=true&sessionVariables=storage_engine=InnoDB You could of course use a real database!

1 comment:

  1. also consider:

    default-table-type = INNODB
    default-storage-engine=InnoDB

    collation_server=utf8_unicode_ci
    character_set_server=utf8

    character-set-client-handshake=FALSE

    ReplyDelete