如何设置 MySQL 使用的默认存储引擎?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3050492/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I set default storage engine used by MySQL?
提问by memilanuk
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?
我一直致力于编写 SQL 来创建一个带有几个默认选项的 MySQL 数据库,包括字符集和排序规则。是否可以将此数据库中表的默认存储引擎设置为 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.
我一直在查看 MySQL 5.1 手册,我找到了ENGINE=innodb
将附加到CREATE TABLE
语句的语句,但我没有找到与CREATE DATABASE
语句相关的任何内容。
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?
作为数据库创建的一部分,是否有一种正常的方法可以做到这一点,还是需要逐个表地指定?
回答by Daniel Vassallo
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 thedefault-storage-engine
option in themy.cnf
configuration file.
如果省略该
ENGINE
选项,则使用默认存储引擎。通常,这是 MyISAM,但您可以通过使用--default-storage-engine
服务器启动选项或default-storage-engine
在my.cnf
配置文件中设置该选项来更改它。
The default-storage-engine option must be part of the mysqld section in my.cnf;
default-storage-engine 选项必须是my.cnf 中mysqld 部分的一部分;
[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:
您可能还想为当前会话更改默认存储引擎。您可以通过设置storage_engine
变量来做到这一点:
SET storage_engine=INNODB;
回答by sml
you need to specify the default storage engine when starting mysqld. for example:
启动mysqld时需要指定默认的存储引擎。例如:
mysqld --default-storage-engine=InnoDB
http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine
http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_default-storage-engine