简体   繁体   English

Mysql'从存储引擎收到错误-1'错误

[英]Mysql 'Got error -1 from storage engine' error

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. 我有一个myism表'test',它包含一些过时的数据,现在我想重新创建表,所有列都相同,只不过我将存储从myism更改为innodb。 The dumped sql I used to recreate the table is like: 我用来重新创建表的转储sql如下:

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. 这就是我收到错误“从存储引擎得到错误-1”的地方,我用Google搜索,大部分结果都集中在损坏的innodb表上。 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. 另一件事是,在执行了上面的sql之后,剩下的用于表测试的是一个名为file.frm的文件,我想innodb表需要运行一些其他东西,但不确定是什么。

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? 我可能需要做更多这类任务,什么是放弃神话表并将其重新创建为innodb的正确程序?

Thanks. 谢谢。

OK. 好。 I found the solution. 我找到了解决方案。 The issue was caused by innodb_force_recovery parameter in my.cnf, that was set to 4. 该问题是由my.cnf中的innodb_force_recovery参数引起的,该参数设置为4。

To solve the problem, set to 0 or completely remove this parameter from my.cnf 要解决此问题,请设置为0或从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: 如果你检查错误日志,在查询期间,mysql将用人类可读的语言写:在启用innodb恢复模式之前,它不会让你更改表中的任何内容,完全是下一条消息:

 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 请参阅: http //bugs.mysql.com/bug.php?id = 30225

A common cause for the -1 error is a full disk. -1错误的常见原因是完整磁盘。 I have different small VMs for testing purposes, and innodb just keeps filling them up (and I keep forgetting about it). 我有不同的小VM用于测试目的,而innodb只是不断填补它们(我一直忘记它)。

$df -ah

If it shows you the disk at 100%, that's the origin of the -1 right there ;) 如果它显示磁盘为100%,那就是-1的原点;)

I had this with an SQL import on Azure and needed to change 我在Azure上使用SQL导入并需要更改

ENGINE=MyISAM with ENGINE=InnoDB ENGINE = MyISAM with ENGINE = InnoDB

Go to /etc/my.cnf 转到/etc/my.cnf

Comment line innodb_force_recovery=1 评论专栏innodb_force_recovery = 1

Save the file and restart mysql 保存文件并重启mysql

To discover what the error code is for any system error code on a unix or linux system, look in errno.h. 要了解unix或linux系统上任何系统错误代码的错误代码,请查看errno.h。 On my mac, I can do: 在我的Mac上,我可以这样做:

$ grep 28 /usr/include/sys/errno.h $ grep 28 /usr/include/sys/errno.h
#define ENOSPC 28 /* No space left on device */ #define ENOSPC 28 / *设备上没有剩余空间* /

On other operating systems, such as linux, there will be some other layers because of machine layer sub includes. 在其他操作系统上,例如linux,由于机器层子包含,会有一些其他层。 But, you should be able to look through those files and find these error definitions. 但是,您应该能够查看这些文件并找到这些错误定义。

Alternatively, use the 'man' command to look for "intro" or other manual pages under section '2', the operating system section. 或者,使用'man'命令查找操作系统部分“2”部分下的“简介”或其他手册页。

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

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