---
slug: "mysql-autoincrement-failed-to-read"
title: "対応方法 When MySQL AutoIncrement Runs Out"
description: "MySQLdb._exceptions.OperationalError: (1467, 'Failed to read auto-increment value from storage engine')\nIn Django, when you specify an implicit id, the above error occurs if the auto increment value reaches its upper limit."
url: "https://www.ytyng.com/en/blog/mysql-autoincrement-failed-to-read"
publish_date: "2020-05-18T02:16:05Z"
created: "2020-05-18T02:16:05Z"
updated: "2026-02-27T08:48:50.496Z"
categories: ["Django"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/1b0719c1c4c840319bdadf46fadcc559.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# 対応方法 When MySQL AutoIncrement Runs Out

<pre>MySQLdb._exceptions.OperationalError: (1467, 'Failed to read auto-increment value from storage engine')</pre>
<p><br />In Django, when you specify an implicit id, the above error occurs if the auto increment value reaches its upper limit.</p>
<p></p>
<p>Checking the database:</p>
<pre>SELECT AUTO_INCREMENT<br />FROM information_schema.tables<br />WHERE TABLE_SCHEMA = 'my_schema'<br /> AND TABLE_NAME = 'my_table';</pre>
<table width="206" height="46">
<tbody>
<tr>
<td>AUTO_INCREMENT</td>
</tr>
<tr>
<td>2147483647</td>
</tr>
</tbody>
</table>
<p></p>
<pre>SHOW CREATE TABLE my_table;<br /><br />CREATE TABLE `my_table` (<br /> `id` int(11) NOT NULL AUTO_INCREMENT,<br />...</pre>
<p></p>
<p>Modifying the model:</p>
<pre>id = models.BigAutoField(primary_key=True)</pre>
<p>Adding the above line</p>
<p></p>
<pre>./manage.py makemigrations</pre>
<pre>./manage.py migrate</pre>
<pre>SHOW CREATE TABLE my_table;<br /><br />CREATE TABLE `my_table` (<br /> `id` bigint(20) NOT NULL AUTO_INCREMENT,<br />...</pre>
<p></p>
