Mysql“来自存储引擎的错误-1”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9595852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 12:23:59  来源:igfitidea点击:

Mysql 'Got error -1 from storage engine' error

mysqlinnodb

提问by Shawn

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:

我有一个 myism 表“test”,其中包含一些过时的数据,现在我想重新创建该表,所有列都相同,只是我将存储从 myism 更改为 innodb。我用来重新创建表的转储 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. While for my case I don't think it's broken, it's just something I missed at the drop and create statements.

这就是我收到错误“来自存储引擎的错误 -1”的地方,我用谷歌搜索,大部分结果都集中在损坏的 innodb 表上。虽然对于我的情况,我认为它没有坏,只是我在下降和创建语句时错过了一些东西。

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?

我该如何解决这个问题?而且我可能需要执行更多此类任务,删除 myism 表并将它们重新创建为 innodb 表的正确程序是什么?

Thanks.

谢谢。

回答by Shawn

OK. I found the solution. The issue was caused by innodb_force_recoveryparameter 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.
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

回答by deimosaffair

A common cause for the -1 error is a full disk. I have different small VMs for testing purposes, and innodbjust keeps filling them up (and I keep forgetting about it).

-1 错误的常见原因是磁盘已满。我有不同的小型虚拟机用于测试目的,并且innodb一直在填满它们(我一直忘记它)。

$df -ah

If it shows you the disk at 100%, that's the origin of the -1right there ;)

如果它以 100% 显示磁盘,那就是-1右侧的原点;)

回答by TheAlbear

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

我在 Azure 上通过 SQL 导入进行了此操作,需要更改

ENGINE=MyISAM with ENGINE=InnoDB

ENGINE=MyISAM 与 ENGINE=InnoDB

回答by HCS420

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

回答by Grwww

To discover what the error code is for any system error code on a unix or linux system, look in errno.h. On my mac, I can do:

要了解 unix 或 linux 系统上任何系统错误代码的错误代码,请查看 errno.h。在我的 Mac 上,我可以:

$ grep 28 /usr/include/sys/errno.h
#define ENOSPC 28 /* No space left on device */

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

On other operating systems, such as linux, there will be some other layers because of machine layer sub includes. But, you should be able to look through those files and find these error definitions.

在其他操作系统上,例如 linux,由于机器层子包含,还会有一些其他层。但是,您应该能够查看这些文件并找到这些错误定义。

Alternatively, use the 'man' command to look for "intro" or other manual pages under section '2', the operating system section.

或者,使用“man”命令在“2”部分(操作系统部分)下查找“介绍”或其他手册页。