简体   繁体   中英

InnoDB converting to MyISAM on Import

I'm running a MySQL 5.1 server under CentOS 6.5. During an import of a SQL file today, all tables were created under MyISAM, even if they were declared to use InnoDB engine.

For example, I had a table declared on the .sql file as this:

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:

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

The customer table was created using the MyISAM table. 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 5.1 have some problems. I prefere to update it.

The other way is to disable different InnoDB settings in your my.cnf until innoDB is running.

 show engine innodb status

With this command you can check the current state. Dont forget to restart mysql after every change.

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 . It will help to avoid the issue. http://dev.mysql.com/doc/refman/5.0/en/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. You can also use show engine innodb status to gather detailed information.

3rd - Since MySQL 5.1 have by default MyISAM as the default engine, set mysql configuration to use InnoDB as the default engine.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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