如何设置MySQL使用的默认存储引擎? [英] How can I set default storage engine used by MySQL?

查看:795
本文介绍了如何设置MySQL使用的默认存储引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直致力于编写SQL来创建一个带有多个默认选项的MySQL数据库,包括字符集和排序规则。是否可以将此数据库中的表的默认存储引擎设置为InnoDB?

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?

我一直在通过MySQL 5.1手册,我发现语句 ENGINE = innodb 附加到 CREATE TABLE 语句,但我没有找到任何与 CREATE DATABASE 语句相关的内容。

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?

推荐答案

引用参考手册(设置存储引擎):


如果省略 ENGINE 选项,则使用默认存储引擎。通常,这是MyISAM,但您可以使用 - default-storage-engine 服务器启动选项,或通过设置< my.cnf 中的 c> default> default-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.

默认存储引擎选项必须是 my.cnf ;

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

[mysqld]
default-storage-engine = innodb

您可能还需要更改当前会话的默认存储引擎。您可以通过设置 storage_engine 变量来执行此操作:

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;

这篇关于如何设置MySQL使用的默认存储引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆