Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql 'Got error -1 from storage engine' error

Tags:

mysql

innodb

I have a myism table 'test' which holds some out-dated data, now I want to recreate the table, all columns the same except that I changed the storage from myism to innodb. The dumped sql I used to recreate the table is like:

drop table test; create table test ( ... ) engine=innodb  insert into test(...) values(...) 

that's where I got the error "Got Error -1 from storage engine", I have googled around, most of the results focus on corrupted innodb tables. While for my case I don't think it's broken, it's just something I missed at the drop and create statements.

Another thing is that is after a executed the above sql, all that's left for table test is a file named file.frm, I guess innodb table needs some other stuff to run on but not sure what.

How can I fix this problem? And I probably need to do more tasks of this kind, what's the correct procedure to drop myism table and recreate them as innodb ones?

Thanks.

like image 620
Shawn Avatar asked Mar 07 '12 04:03

Shawn


People also ask

What is the storage engine for MySQL?

InnoDB : The default storage engine in MySQL 8.0. InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data.


2 Answers

OK. I found the solution. The issue was caused by innodb_force_recovery parameter in my.cnf, that was set to 4.

To solve the problem, set to 0 or completely remove this parameter from my.cnf

If you check error log, during query, mysql will write in human readable language that: It won't let you change anything in table until innodb recovery mode is enabled, exactly next message:

InnoDB: A new raw disk partition was initialized or InnoDB: innodb_force_recovery is on: we do not allow InnoDB: database modifications by the user. Shut down InnoDB: mysqld and edit my.cnf so that newraw is replaced InnoDB: with raw, and innodb_force_... is removed. 

Please refer to: http://bugs.mysql.com/bug.php?id=30225

like image 156
Shawn Avatar answered Sep 25 '22 14:09

Shawn


I had this with an SQL import on Azure and needed to change

ENGINE=MyISAM with ENGINE=InnoDB

like image 38
TheAlbear Avatar answered Sep 26 '22 14:09

TheAlbear