Skip to content

A lightweight PHP tool that scans MySQL/MariaDB databases for integrity issues, corrupted indexes, and duplicate values in UNIQUE/PRIMARY keys.

License

Notifications You must be signed in to change notification settings

BaseMax/mysql-database-integrity-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MySQL Database Integrity Checker

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.


🚀 Features

✔ 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)


📸 Screenshot

Preview


📦 Requirements

  • PHP 7.4+ (works with PHP 8.x)
  • MySQL or MariaDB
  • Web server (Apache, Nginx, PHP Built-in server, etc.)

No external libraries required.


🛠 Installation

Clone the repository:

git clone https://github.com/BaseMax/mysql-database-integrity-checker
cd mysql-database-integrity-checker

Place 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/

🧪 Usage

  1. Open the script in your browser.
  2. Enter MySQL connection details:
    • Host (default: localhost)
    • Port (default: 3306)
    • Username
    • Password
    • Database name
  3. Click Run check.

The script will:

✔ Validate the connection

  • ✔ 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

🔍 What Problems Does This Detect?

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

❗ What This Tool Does Not Do

  • 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.


📄 License

This project is licensed under the MIT License. See the full text in LICENSE.


👤 Author

Seyyed Ali Mohammadiyeh (Max Base) GitHub: https://github.com/BaseMax


⭐ Contributing

Pull requests are welcome! If you find a bug or want a feature, open an issue in the repository.


❤️ Support

If you find this useful, please give the repo a ⭐ on GitHub it helps more people discover it!

About

A lightweight PHP tool that scans MySQL/MariaDB databases for integrity issues, corrupted indexes, and duplicate values in UNIQUE/PRIMARY keys.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages