Local PHP tool to extract ordered seed.sql files from MySQL/phpMyAdmin exports.
- Upload a
.sqlfile exported from phpMyAdmin. - Parse
CREATE TABLE,ALTER TABLE ... FOREIGN KEY, and multi-rowINSERT INTO. - Detect tables, columns, primary keys, foreign keys, and dependency order.
- Select one or more tables for export.
- Include only selected tables, full parent tables, or FK-related parent rows.
- Preview the generated SQL before downloading.
- Export
seed_selected_tables.sqlwith optionalSET FOREIGN_KEY_CHECKS=0.
- PHP 8.1 or newer.
- XAMPP, LAMPP, DDEV, or any local PHP server.
- No database connection is required for the first version.
From the project directory:
php -S localhost:8000Then open:
http://localhost:8000
With XAMPP/LAMPP, copy the mysql-seed-extractor folder into htdocs, then open:
http://localhost/mysql-seed-extractor
Use the included file:
examples/sample.sql
CLI test:
php tools/test_sample.phpRecommended test:
- Upload
examples/sample.sql. - Select
posts. - Keep
الجداول المختارة + السجلات المرتبطة فقط. - Preview the seed.
Expected result:
rolesappears first.usersappears second.postsappears last.- Only the parent rows required by selected post rows are included.
index.php
src/
SqlTokenizer.php
SqlParser.php
SchemaAnalyzer.php
ForeignKeyResolver.php
SeedGenerator.php
assets/
css/app.css
js/app.js
storage/
uploads/
cache/
examples/
sample.sql
This version is intentionally local-first. It does not execute imported SQL against a real MySQL server. The parser reads the SQL text, builds a schema model, resolves dependencies, and generates a new seed file from the parsed inserts.
For very complex dumps, the next improvement would be adding optional support for a mature MySQL parser library or importing into a temporary isolated database for deeper FK and row filtering.