A lightweight, self-contained PHP tool for validating MySQL/MariaDB databases, checking for:
- Invalid or missing database credentials
- Database existence
- Missing tables
- Corrupted UNIQUE / PRIMARY indexes
- Duplicate values inside UNIQUE or PRIMARY key columns ( caused by MySQL/MariaDB index corruption, crashes, or improper validation )
This tool helps detect silent database corruption that MySQL/MariaDB sometimes allows for example multiple rows sharing a unique ID such as 0 or other values.
✔ Simple HTML form interface
✔ Minimal CSS UI
✔ Works via browser no installation required
✔ Validates database connection
✔ Lists all tables in the database
✔ Automatically detects UNIQUE and PRIMARY indexes
✔ Scans tables for duplicate values in these keys
✔ Handles MySQL/MariaDB edge cases where corruption allows invalid duplicates
✔ Outputs structured and readable results
✔ Fully standalone (no frameworks, no composer)
- PHP 7.4+ (works with PHP 8.x)
- MySQL or MariaDB
- Web server (Apache, Nginx, PHP Built-in server, etc.)
No external libraries required.
Clone the repository:
git clone https://github.com/BaseMax/mysql-database-integrity-checker
cd mysql-database-integrity-checkerPlace the project in a public folder such as:
/var/www/html/mysql-database-integrity-checker
Then open in your browser:
http://localhost/mysql-database-integrity-checker/
- Open the script in your browser.
- Enter MySQL connection details:
- Host (default:
localhost) - Port (default:
3306) - Username
- Password
- Database name
- Host (default:
- Click Run check.
The script will:
- ✔ Check the database exists
- ✔ List tables
- ✔ Warn if there are no tables
- ✔ For each table:
- Identify PRIMARY and UNIQUE indexes
- Group data and detect duplicates
- ✔ Display duplicate rows with counts
- ✔ Display index errors or anomalies
This tool finds structural integrity issues such as:
- Duplicate PRIMARY key values
- Duplicate values on UNIQUE indexes
- Failed MySQL/MariaDB constraints after crashes
- Corrupted auto-increment behavior
- Improper schema repairs
- Damaged or inconsistent index data
- It does not automatically delete duplicate rows
- It does not modify your database
- It does not attempt automatic repair
If you want, I can add optional:
- auto-repair mode
- CSV export
- "suggested fix" buttons
- WP-specific repair commands
Just ask.
This project is licensed under the MIT License.
See the full text in LICENSE.
Seyyed Ali Mohammadiyeh (Max Base) GitHub: https://github.com/BaseMax
Pull requests are welcome! If you find a bug or want a feature, open an issue in the repository.
If you find this useful, please give the repo a ⭐ on GitHub it helps more people discover it!
