设置mysql引擎_如何设置MySQL使用的默认存储引擎?

bd96500e110b49cbb3cd949968f18be7.png

I've been working on writing SQL to create a MySQL database with several default options, including character set and collation. Is it possible to set the default storage engine for tables in this database to InnoDB?

I've been looking through the MySQL 5.1 manual and I've found the statement ENGINE=innodb which would be appended to a CREATE TABLE statement, but I haven't found anything related to a CREATE DATABASE statement.

Is there a normal way to do this as part of the database creation, or does it need to be specified on a table-by-table basis?

解决方案

Quoting the Reference Manual (Setting the Storage Engine):

If you omit the ENGINE option, the default storage engine is used. Normally, this is MyISAM, but you can change it by using the --default-storage-engine server startup option, or by setting the default-storage-engine option in the my.cnf configuration file.

The default-storage-engine option must be part of the mysqld section in my.cnf;

[mysqld]

default-storage-engine = innodb

You may also want to change the default storage engine just for the current session. You can do this by setting the storage_engine variable:

SET storage_engine=INNODB;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值