开发者

How do I set MyISAM as default table handler in MySQL?

开发者 https://www.devze.com 2023-03-15 15:23 出处:网络
I want all my tables and the whole database to use MyISAM engine. My Project uses MyISAM database exclusively.

I want all my tables and the whole database to use MyISAM engine.

My Project uses MyISAM database exclusively.

I want the 开发者_如何学JAVAdefault table handler for all tables to be MyISAM.


UPDATE: InnoDB has been the default storage engine since MySQL 5.5.5. MyISAM is now legacy but still exists.

Also the default-table-type option was a synonym for default-storage-engine and was removed in MySQL 5.5. And, as of MySQL 5.6.3, default-storage-engine sets the storage engine for permanent tables only.


To see what your default storage engine currently is do: mysql> SHOW engines; MyISAM has long been the default, but someone might have changed it.

To change your default storage engine back to MyISAM, put

default-table-type=myisam

under the [mysqld] section in your my.cnf and restart mysqld.

To change existing tables back to MyISAM do:

ALTER TABLE tbl_name ENGINE=MyISAM;

Also, databases don't have storage engines, tables do. Therefore to see which engine a table is using:

SHOW CREATE TABLE tbl_name; or SHOW TABLE STATUS LIKE 'tbl_name'\G


For MySQL 5.7, add this line:

default-storage-engine=INNODB

in my.ini or my.cnf.

Official documentation here: https://dev.mysql.com/doc/refman/5.7/en/storage-engine-setting.html

This worked for me in WAMP 3.0.6 with MySQL 5.7.14, that comes with MyISAM as the default out of the box, even though the MySQL documentation states "The default engine is InnoDB in MySQL 5.7".

This is explained by WAMP developers:

"We were spending an inordinate amount of time on questions about INNODB database corruption.

This we believed was due to people using INNODB databases and not understanding that these tables are more complex. They were just closing windows and killing jobs on shutdown before MYSQL had a chance to cleanly shutdown all its databases and of course never taking a backup of databases that once corrupted were suddenly the most important thing in there lives.

So we decided to make the default database engine MYISAM as this is less likely to happen with these tables."


MyISAM is the default storage engine. However if it is not in your case, you can do any of the following:

  1. change it using the --default-storage-engine during your MySQL server startup,
  2. by setting the default-storage-engine in the my.cnf configuration file
  3. by setting the env variable:

SET GLOBAL storage_engine = MyISAM;

SET SESSION storage_engine = MyISAM;
0

精彩评论

暂无评论...
验证码 换一张
取 消