Mysql中的默认存储引擎
作者:老王笔记
这篇文章主要介绍了Mysql中的默认存储引擎方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
Mysql在V5.1之前默认存储引擎是MyISAM;
在此之后默认存储引擎是InnoDB
查看默认存储引擎
查看当前mysql默认引擎: show variables like '%engine%';
mysql> show variables like '%engine%'; +----------------------------------+--------+ | Variable_name | Value | +----------------------------------+--------+ | default_storage_engine | InnoDB | | default_tmp_storage_engine | InnoDB | | disabled_storage_engines | | | internal_tmp_disk_storage_engine | InnoDB | +----------------------------------+--------+ 4 rows in set (0.00 sec)
查看mysql支持哪些引擎:show engines;
- Engine是引擎名字,
- Support 显示Innodb是DEFAULT默认的;
- Commnet是简单描述
- Transactions: 是否支持事物
mysql> show engines; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | CSV | YES | CSV storage engine | NO | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 9 rows in set (0.00 sec)
修改默认存储引擎
如果修改本次会话的默认存储引擎(重启后失效),只对本会话有效,其他会话无效:
mysql> set default_storage_engine=innodb; Query OK, 0 rows affected (0.00 sec)
修改全局会话默认存储引擎(重启后失效),对所有会话有效
mysql> set global default_storage_engine=innodb; Query OK, 0 rows affected (0.00 sec)
希望重启后也有效,即编辑/etc/my.cnf,[mysqld]下面任意位置添加配置;(所有对配置文件的修改,重启后生效)
default-storage-engine = InnoDB
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。