Saturday, April 3, 2010

to set default engine in mysql

Mysql's default engine is not set for foreign key constraints which really bugs me out. So I was looking for a trick to set the default engine to innodb and I finally got this worked.

The default storage engine can be changed at server startup or at runtime:
  • 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 = engine_name;
    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 = engine_name;
    SET storage_engine = engine_name;
    ps: I wrote "innodb" instead of "engine_name" 
    this will only change the default engine for temporary. If you would like to set it permanently 
    you should edit the /etc/mysql/my.cnf file.

    Then under the [mysqld] add the following line as shown below! [mysqld] default-storage_engine = innodb ...

    Finally, restart mySQL;
    $ sudo service mysql restart


No comments:

Post a Comment