How do I set MyISAM as default table handler in MySQL?
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:
- change it using the --default-storage-engine during your MySQL server startup,
- by setting the default-storage-engine in the my.cnf configuration file
- by setting the env variable:
SET GLOBAL storage_engine = MyISAM;
SET SESSION storage_engine = MyISAM;
精彩评论