MySQL Variables keep_files_on_create 数据库 参数变量解释及正确配置使用
本站中文解释
keep_files_on_create参数意味着,在数据库引擎创建新表时,如果发生错误,就会保留引擎可能创建的文件。默认情况下,MySQL会根据create语句的指定参数,自动创建表空间文件,但是在执行create语句时如果发生错误,就会删除这些文件。
设置Keep_files_on_create参数的方法:
1. 使用MySQL的my.cnf或my.ini配置文件来设置参数:
将以下行添加到mysql的配置文件中:[mysqld]
keep_files_on_create = 1
2. 使用SET GLOBAL语句在运行时设置参数:
SET GLOBAL keep_files_on_create = 1;
官方英文解释
keep_files_on_create
Command-Line Format | --keep-files-on-create[={OFF|ON}] |
---|---|
System Variable | keep_files_on_create |
Scope | Global, Session |
Dynamic | Yes |
Type | Boolean |
Default Value | OFF |
If a MyISAM
table is created with no
DATA DIRECTORY
option, the
.MYD
file is created in the database
directory. By default, if MyISAM
finds an
existing .MYD
file in this case, it
overwrites it. The same applies to .MYI
files for tables created with no INDEX
option. To suppress this behavior, set the
DIRECTORY
keep_files_on_create
variable
to ON
(1), in which case
MyISAM
does not overwrite existing files
and returns an error instead. The default value is
OFF
(0).
If a MyISAM
table is created with a
DATA DIRECTORY
or INDEX
option and an existing
DIRECTORY
.MYD
or .MYI
file is
found, MyISAM always returns an error. It does not overwrite a
file in the specified directory.