当前位置: 代码网 > it编程>数据库>Mysql > Mysql中的默认存储引擎

Mysql中的默认存储引擎

2024年05月28日 Mysql 我要评论
mysql在v5.1之前默认存储引擎是myisam;在此之后默认存储引擎是innodb查看默认存储引擎查看当前mysql默认引擎:show variables like '%engine%&#

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

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com