mysql 从存储引擎读取自增值失败

发布于 2024-12-03 16:34:27 字数 252 浏览 3 评论 0原文

我有一个 mysql 表,其中一个 id 字段作为自动增量。

当我向表中插入值时出现错误

1467 - 无法从存储引擎读取自动增量值

显示表状态还显示具有自动增量的字段具有

18446744073709551615作为Auto_increment值。

任何人都可以帮助我......会出现什么问题吗?

I am having mysql table with one id field as auto-increment .

When I insert values to the table am getting error as

1467 - Failed to read auto-increment value from storage engine

Also the show table status shows me that the field with auto increment has

18446744073709551615 as Auto_increment value.

What would be the issue can any one help me ....?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

静待花开 2024-12-10 16:34:27

我遇到了同样的错误,但就我而言,表中有大约 1.5k 条记录。
我通过像这样重置自动增量来修复它:

ALTER TABLE `table_name`  AUTO_INCREMENT = 1

I had the same error but in my case I had about 1.5k records in the table.
I fixed it by resetting the AUTO INCREMEN like that:

ALTER TABLE `table_name`  AUTO_INCREMENT = 1
初见你 2024-12-10 16:34:27

几周前,我在运行插入语句时开始收到此错误:

Duplicate entry '127' for key 'PRIMARY'

...即使我的表设置为自动增量。我进去并将 auto_increment 值从 127 更改为 128,然后我开始收到此错误:

1467 - Failed to read auto-increment value from storage engine

我最终发现该表最初是使用tinyint 列创建的,ID 不是标准整数......所以基本上它无法理解数字大于 127。我将列类型切换为正确的整数,这解决了问题。

希望对某人有帮助:)

I started getting this error a couple of weeks back when running insert statements:

Duplicate entry '127' for key 'PRIMARY'

... even though my table was set to auto increment. I went in and changed the auto_increment value from 127 to 128 then I started getting this error:

1467 - Failed to read auto-increment value from storage engine

I eventually figured out that the table had been initially created with tinyint columns for the ID not standard ints ... so basically it couldn't comprehend numbers bigger than 127. I switched the column type to proper integers and that solved the issue.

Hope that helps someone :)

窝囊感情。 2024-12-10 16:34:27

问题绝对可能是这样的:将 18446744073709551615 转换为十六进制,你会发现
$FFFF-FFFF-FFFF-FFFF
如果您的字段是无符号 64 位,您就达到了其限制。

Problem could absolutely be that: convert 18446744073709551615 to hex and you'll find
$FFFF-FFFF-FFFF-FFFF.
If your field is an unsigned 64bit you reach its limit.

只有一腔孤勇 2024-12-10 16:34:27

就我而言,我犯了一个愚蠢的错误。我之前更改了表,并将 AUTO_INCRMENT 列的名称从 ID 更改为 id。因此,给定的列名区分大小写,后续插入无法找到原始列。

For my part, I made a dumb mistake. I had earlier altered my table and changed the name of the AUTO_INCREMENT column from ID to id. So, given column names are case-sensitive, subsequent inserts couldn't find the original column.

你在我安 2024-12-10 16:34:27

实际上,您可以简单地更改该列以删除其 auto_increment 属性,然后再次将其设置为 auto_increment 。在我这边,这种方法确实有效。

Actually, you can simply alter the column to delete its auto_increament property and set it as auto_increment again. On my side, this way did work.

对风讲故事 2024-12-10 16:34:27

我也犯同样的错误。我只是更改表并增加自动增量字段的大小,然后运行以下查询 -

ALTER TABLE `table_name`  AUTO_INCREMENT = 6221;

其中 6221 是 Auto_increment 字段的最后一个值。

I go the same error. I just alter the table and increase the size of my auto increment field and then run the following query -

ALTER TABLE `table_name`  AUTO_INCREMENT = 6221;

where 6221 is the last value of the filed with Auto_increment.

风透绣罗衣 2024-12-10 16:34:27

不到一个小时前,我第一次遇到这个错误。在 PHP MyAdmin 中使用 SQL 语句重置 auto_increment 失败。在寻找解决方案后,我删除了该表并创建了一个替换表。错误依然存在。仔细观察发现,即使我在创建字段时专门设置了 Primary_key 和 auto_increment,auto_increment 也设置为 0。再次使用 PHP MyAdmin 手动将 auto_increment 重置为 1,消除了错误。幸运的是,我只使用包含几行测试数据的 3 列表。

I experienced this error for the first time less than an hour ago. Resetting the auto_increment using a SQL statement in PHP MyAdmin failed. After looking for a solution I dropped the table and created a replacement. The error remained. Looking closer revealed the auto_increment was set to 0 even though I had specifically set the primary_key and auto_increment while creating the fields. Manually resetting auto_increment to 1, again using PHP MyAdmin, eliminated the error. Luckily for me I was only working with a 3-column table containing a few rows of test data.

独木成林 2024-12-10 16:34:27

我通过删除自动增量、保存表然后再次添加自动增量来修复它。

I fixed it by removing the auto increment , saving table and then add auto increment again.

以酷 2024-12-10 16:34:27

我今天也遇到这个问题了。我有一个包含超过 200 万行的表,并在发生此错误时尝试使用 LOAD DATA 添加另外 140K 行。我切换到 MyISAM 引擎,一切正常。

I had this problem today, too. I have a table with over two million rows and tried to add another 140K rows with LOAD DATA when this error occurred. I switched to the MyISAM engine and it all worked.

拔了角的鹿 2024-12-10 16:34:27

我遇到了同样的问题,解决方案是将列从smallint(6) 更改为int。

I had the same problem and the solution was to change the column from smallint(6) to int.

只涨不跌 2024-12-10 16:34:27

我遇到了问题,auto_increment 设置为 0,但显式设置 auto_increment 不起作用(保持为 0)。
我使用 ID 手动输入一个条目,之后该值就设置正确了。

I had the problem, that the auto_increment was set to 0, but setting the auto_increment explicitly did not work (stayed at 0).
I entered an entry manually with an ID and after this, the value was set right.

疑心病 2024-12-10 16:34:27

我解决了这个问题,取消选中该字段的选项 AUTO_INCRMENT 并再次检查

I resolve this problem uncheck the option AUTO_INCREMENT of the field and check again

不美如何 2024-12-10 16:34:27

我的解决方法是更改​​表并将其重命名为 orignal_backup 之类的名称并保存,然后再次将其重命名回原始表,这个技巧对我有用。

My workaround was to alter the table and rename it to something like orignal_backup and save, then again rename it back to orignal one, this trick worked for me.

对风讲故事 2024-12-10 16:34:27

今天,当我尝试将记录插入名为 mytablename 的表时,出现同样的错误:

ERROR 1467 (HY000): Failed to read auto-increment value from storage engine

在表中我只有 52269 条记录,max(id) = 52269。
我已尝试在 mysql 命令控制台下执行以下命令,但没有任何反应,错误仍然存​​在:

#
# set  AUTO_INCREMENT  = max(id) + 1: not work:
#
ALTER TABLE mytablename AUTO_INCREMENT = 52270;

我必须找到另一个解决方案。当我这样做时:

SHOW TABLE STATUS FROM mydatabase WHERE `name` LIKE 'mytablename' ;

它显示我的 Auto_Increment 值为 0,这显然是错误的,它必须大于或等于 1。

我修改了表中的任何列,如下所示:

ALTER TABLE mytablename CHANGE COLUMN mycharfield mycharfield varchar(255) DEFAULT NULL AFTER id;

我再次执行 show table status 命令,

Auto_Increment 值已自动更改为52270,非常有价值。

一切从那时起...

Today, I've the same error when I tried to insert a record into a table named mytablename:

ERROR 1467 (HY000): Failed to read auto-increment value from storage engine

In the table I've only 52269 records, max(id) = 52269.
I've tried following command under mysql command console, but nothing takes place, error persists:

#
# set  AUTO_INCREMENT  = max(id) + 1: not work:
#
ALTER TABLE mytablename AUTO_INCREMENT = 52270;

I must find another solution. When I do:

SHOW TABLE STATUS FROM mydatabase WHERE `name` LIKE 'mytablename' ;

It shows that my Auto_Increment value is 0, that is clearly in error, it must be greater or equal to 1.

I modified any colum in the table like:

ALTER TABLE mytablename CHANGE COLUMN mycharfield mycharfield varchar(255) DEFAULT NULL AFTER id;

I do again the show table status command,

Auto_Increment value has been automatically changed to 52270, that is good value.

All goes since then...

坠似风落 2024-12-10 16:34:27

我也有同样的问题。

原因:我用主键和自动增量属性更改了表字段名称,因此自动增量停止工作并出现错误1467。

对我有用的是重置 phpmyadmin 中的主键,如下所示:

  1. 转到表的“结构”选项卡并单击“indexex”,如图 1 所示。
  2. 现在编辑主键,如图 1 所示。
  3. 只需单击“Go”,如图 1 所示2.

图片 1

Image 2

它对我有用。

I had the same problem.

Reason: I have changed the name of my table field's name with primary key and auto increment property, due to which auto increment stopped working and the error 1467 appeared.

What worked for me is resetting the primary key in phpmyadmin as shown below:

  1. Goto 'Structure' tab of table and click on 'indexex' as shown in Image 1.
  2. Now edit the primary key as in Image 1.
  3. Simply click Go as in Image 2.

Image 1

Image 2

It worked for me.

空气里的味道 2024-12-10 16:34:27

我发现该参数已启用。根据数据库专家的说法,它不应超过“1”……

在我的例子中,它被设置为“4”,如下所示。

mysql>选择@@innodb_force_recovery;
+------------------------------------+
| @@innodb_force_recovery |
+------------------------------------+
| 4 |
+------------------------------------+

因此,我确实在启动过程中没有传递参数的情况下重新启动了mysql,

后来我能够插入或更新表...希望它能帮助某人..

I have found the parameter was enabled. it should not be more than '1' as per DB-experts....

In my case it was set to '4', shown below.

mysql> select @@innodb_force_recovery;
+-------------------------+
| @@innodb_force_recovery |
+-------------------------+
| 4 |
+-------------------------+

Hence, i did restart the mysql without passing the parameter during startup ,

later i was able to insert or update the tables ...hope it will help someone ..

忆悲凉 2024-12-10 16:34:27

很容易就修好了。截断表并再次上传数据,错误消失。

fixed it very easily. Truncated the table and uploaded the data again and the error disappears.

本王不退位尔等都是臣 2024-12-10 16:34:27

我有同样的问题。我有一个包含数千条记录的表。我刚刚将字段的类型从 int 更改为 bigint

I have the same issue. I have a table with thousands of records. I just changed the type of the field from int to bigint

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文