简体   繁体   English

InnoDB在导入时转换为MyISAM

[英]InnoDB converting to MyISAM on Import

I'm running a MySQL 5.1 server under CentOS 6.5. 我正在CentOS 6.5下运行MySQL 5.1服务器。 During an import of a SQL file today, all tables were created under MyISAM, even if they were declared to use InnoDB engine. 在今天导入SQL文件的过程中,即使已声明使用InnoDB引擎,所有表也是在MyISAM下创建的。

For example, I had a table declared on the .sql file as this: 例如,我在.sql文件中声明了一个表,如下所示:

CREATE TABLE `customer` (
  `customer_id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_no` varchar(20) DEFAULT NULL,
  `company_name` varchar(50) DEFAULT NULL,
[....]
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT

When the .sql file was imported using: 使用以下命令导入.sql文件时:

mysql -u <username> -p < new_db.sql

The customer table was created using the MyISAM table. 客户表是使用MyISAM表创建的。 How can this be possible? 这怎么可能?

To fix the issue I have added on MySQL config to set the default engine to InnoDB and restarted but, since the table engine was declared to be InnoDB, shouldn't it be loaded using that declared engine instead of the default ? 为了解决这个问题,我在MySQL config上添加了将默认引擎设置为InnoDB并重新启动的方法,但是由于表引擎被声明为InnoDB,因此不应该使用该声明的引擎而不是默认引擎来加载它吗?

MySQL 5.1 have some problems. MySQL 5.1有一些问题。 I prefere to update it. 我更喜欢更新它。

The other way is to disable different InnoDB settings in your my.cnf until innoDB is running. 另一种方法是禁用my.cnf中的其他InnoDB设置,直到运行innoDB。

 show engine innodb status

With this command you can check the current state. 使用此命令可以检查当前状态。 Dont forget to restart mysql after every change. 每次更改后,请不要忘记重启mysql。

After a long time searching for an explanation of the issue I have found none, but there are ways to prevent the issue and to fix it. 在长时间寻找问题的解释之后,我没有找到任何答案,但是有一些方法可以防止该问题并加以解决。

1st - Check this MySQL configuration: no engine substitution . 1-检查此MySQL配置: no engine substitution It will help to avoid the issue. 这将有助于避免该问题。 http://dev.mysql.com/doc/refman/5.0/en/sql-mode.html#sqlmode_no_engine_substitution http://dev.mysql.com/doc/refman/5.0/zh-CN/sql-mode.html#sqlmode_no_engine_substitution

2nd - When the error is happening, use both show_warnings and show_engines to see any errors that occurred and to see if InnoDb is enabled. 第二-发生错误时,请同时使用show_warningsshow_engines查看发生的任何错误并查看是否启用了InnoDb。 You can also use show engine innodb status to gather detailed information. 您还可以使用show engine innodb status来收集详细信息。

3rd - Since MySQL 5.1 have by default MyISAM as the default engine, set mysql configuration to use InnoDB as the default engine. 第三-由于MySQL 5.1默认具有MyISAM作为默认引擎,因此将mysql配置设置为使用InnoDB作为默认引擎。

default-storage-engine=InnoDB
default-table-type=InnoDB

And if all of that fails and you can't still find out why or what is happening, then, this might help: 如果所有这些都失败了,而您仍然无法找出原因或发生了什么,那么这可能会有所帮助:

$ sudo service mysqld stop
$ mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bak
$ mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bak
$ sudo service mysqld start

It doesn't properly explain why the issue happened but it will help solve it. 它不能正确解释问题发生的原因,但可以帮助解决问题。 My next step is verify if the server and application will support a MySQL update to 5.5 我的下一步是验证服务器和应用程序是否支持将MySQL更新到5.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM