PHPackages                             j0celyn/ibd2mysql - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. j0celyn/ibd2mysql

ActiveProject[Database &amp; ORM](/categories/database)

j0celyn/ibd2mysql
=================

Tool to recover InnoDB tables in a corrupted MySQL database or MySQL server

v1.0.1(2y ago)583↓83.3%2[2 issues](https://github.com/J0celyn/ibd2mysql/issues)MITPHPPHP &gt;=8.0.0

Since Aug 10Pushed 2y ago2 watchersCompare

[ Source](https://github.com/J0celyn/ibd2mysql)[ Packagist](https://packagist.org/packages/j0celyn/ibd2mysql)[ RSS](/packages/j0celyn-ibd2mysql/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)DependenciesVersions (3)Used By (0)

ibd2mysql
=========

[](#ibd2mysql)

[![Latest Packagist release](https://camo.githubusercontent.com/4b1d6b9cf3fdfc1512a88f8778c9b5d8e7ba42f24d385f1c6112fd5b957ecadd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a3063656c796e2f696264326d7973716c2e737667)](https://packagist.org/packages/j0celyn/ibd2mysql)[![Latest Packagist release](https://camo.githubusercontent.com/7dc2a5f631cf51f201985c02658d91d9170ae34893a748d2abd6f4898fd33176/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6a3063656c796e2f696264326d7973716c2f706870)](https://packagist.org/packages/j0celyn/ibd2mysql)[![Latest Packagist release](https://camo.githubusercontent.com/6ca694fab23c6f53a3b09b3a375fccc26583bbb3434bfa84c67a9913bc0d2341/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a3063656c796e2f696264326d7973716c)](https://packagist.org/packages/j0celyn/ibd2mysql)

Description
-----------

[](#description)

MySQL provides the configuration flag [innodb\_force\_recovery](https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html) to help you fix several kinds of errors.
You should first check if it can help you fix your problems.

**ibd2mysql** is a utility to try to recover InnoDB tables under the following conditions:

- MySQL Server v8.0.0 or newer
- your tables are using the InnoDB engine
- [innodb\_file\_per\_table](https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_file_per_table) was enabled in the MySQL Server configuration **before** you ran into problems
    (in the MySQL data directory, you should see at least one IBD file for each of your tables)
- the MySQL data dictionary is corrupted or missing (the server no longer knows what tables each database contains, despite the IBD files still being there)

Features
--------

[](#features)

- batch extract SDI information from your IBD data files
- batch re-create your tables' SQL structure
- batch re-create your databases and your tables, using your IBD data files

**Note:** This utility is not able to recover MySQL triggers, MySQL events and MySQL user-created routines (functions and procedures).

Requirements
------------

[](#requirements)

- PHP 8
- MySQL 8

Installation
------------

[](#installation)

This composer command will create a new directory **ibd2mysql** and install the files there:

```
composer create-project j0celyn/ibd2mysql ibd2mysql

```

Setup
-----

[](#setup)

⚠️ The IBD file format evolving with each MySQL version, it is highly recommended to run this script using the version of the MySQL Server that created the IBD files you are trying to recover.
If using a different MySQL version, you will probably still be able to extract the SDI information and create the SQL files. However the **--repair** option is likely to fail with fatal errors when importing your IBD files into the MySQL Server.

Rename `config-empty.php` to `config.php`, then edit its values:

- **DB\_HOST**: your MySQL server host
- **DB\_PORT**: your MySQL server port
- **DB\_USER**: your MySQL server user
- **DB\_PASSWORD**: your MySQL server password
- **MYSQL\_DATA\_DIR**: full path to the MySQL data directory of your server
- **IBD2SDI\_PATH**: full path to the directory that holds the [ibd2sdi](https://dev.mysql.com/doc/refman/8.0/en/ibd2sdi.html) program. It was probably installed together with your MySQL server
- **BACKUP\_DIR**: full path to the directory of backup IBD files (the IBD files that contain your MySQL data)
- **OUTPUT\_DIR**: full path to the directory where this script will create SDI and SQL files

Usage
-----

[](#usage)

Here are the available options:

- **--sdi**: extracts SDI information from IBD files.
    **Note: Existing SDI files will be overwritten.**
- **--sql**: creates MySQL files from SDI files (table columns, indexes, partitions and foreign keys)
    **Note: Existing SQL files will be overwritten.**
- **--repair**: for each table:

    - runs the MySQL files to create the table
    - moves IBD file(s) to replace the empty tablespace with your saved tablespace
    - if needed, optimizes the table to fix some issues

        **Note: Existing MySQL tables will not be altered.**

When the script is called with more than one option, they will always run in the same order: **sdi sql repair**

To run the script, use one or more options.

### Examples:

[](#examples)

```
php convert.php --sdi
php convert.php --sdi --sql
php convert.php --sdi --sql --repair

```

Why this utility?
-----------------

[](#why-this-utility)

While upgrading my local MySQL server, I chose the wrong option and it initialized a new MySQL dictionary, thus wiping the current MySQL dictionary.
As I used [innodb\_file\_per\_table](https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_file_per_table) I knew my tables were still there, but the MySQL server had no knowledge of them anymore.
For most of my local databases I had a backup I could restore them from.
A few databases didn't contain valuable information and it didn't matter if they were lost.
And there were a few other databases without backup, I wanted to recover, if still possible.

I tried to find an existing command or utility to recover my databases, but couldn't find anything.
The configuration flag [innodb\_force\_recovery](https://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html) was useless to fix my problems. The utility **ibd2sdi** provided with the MySQL server is useful to get the SDI data from a table (table information in JSON format)...but there's no utility to convert this SDI data into proper MySQL statements that can be run to recreate a table.

Then I decided to create this utility.

**ibd2mysql** was tested with IBD files created by MySQL 8.0.23 (the version I had before I performed the update and destroyed the MySQL dictionary). I could successfully recover all my files :

- 30 MySQL databases
- more than 11600 tables in total

As long as there are no breaking changes in the SDI file format, this utility may work with MySQL Server 8.0.23 and newer versions.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

1057d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2925559?v=4)[Jocelyn](/maintainers/J0celyn)[@J0celyn](https://github.com/J0celyn)

---

Top Contributors

[![J0celyn](https://avatars.githubusercontent.com/u/2925559?v=4)](https://github.com/J0celyn "J0celyn (2 commits)")

---

Tags

mysqlInnoDB

### Embed Badge

![Health badge](/badges/j0celyn-ibd2mysql/health.svg)

```
[![Health](https://phpackages.com/badges/j0celyn-ibd2mysql/health.svg)](https://phpackages.com/packages/j0celyn-ibd2mysql)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58825.9M54](/packages/scienta-doctrine-json-functions)[cytopia/mysqldump-secure

Secure mysqldump script with encryption, compression, logging, blacklisting and Nagios monitoring integration

1474.7k1](/packages/cytopia-mysqldump-secure)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
