This project includes PHP scripts designed for managing SQL databases, particularly useful for environments where only FTP access is available and direct database access is restricted. These scripts facilitate the dumping and restoring of databases, as well as converting the encoding of SQL dump files.
Contains all configuration settings, including database connections, file paths, and encoding specifications.
Dumps the entire database into SQL files, with each file containing commands to recreate tables and insert data.
Reads SQL files generated by dump.php and executes them to restore tables and data.
Converts the encoding of SQL files from one character set to another, useful for database portability and data integrity across different systems.
Allows downloading of a zipped SQL dump files directly from the browser, useful for manual backups or sharing with others.
Uploads a zipped SQL dump file and extracts it to the specified directory for further processing.
Check the web and MySQL server health and settings, outputting the results in a readable format.
Checks the integrity of the database, reporting on available tables, their row counts, encoding and collation settings. Also performs a database health check.
Repairs and optimizes all tables in the database, improving performance and reducing disk space usage.
Edit settings.php to set up the following configurations:
- DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME: Database connection details.
- DUMP_DIR: Path where SQL dump files will be stored.
- ENCODED_DIR: Path for storing encoded SQL files.
- ORIGINAL_ENCODING: Current encoding of SQL files (e.g., 'Windows-1251').
- TARGET_ENCODING: Desired encoding for SQL files (e.g., 'UTF-8').
Ensure that the specified directories (DUMP_DIR and ENCODED_DIR) exist and are writable.
-
Dumping the Database: Navigate to
dump.phpthrough your web browser. This script will save each table's SQL dump in the specified folder. -
Restoring the Database:
Openupload.phpin your browser to execute the SQL files found inDUMP_DIRand restore the database. -
Converting File Encoding:
Accessencode.phpto convert SQL files fromORIGINAL_ENCODINGtoTARGET_ENCODING, saving the new files inENCODED_DIR. -
Downloading SQL Dumps: Open
download.phpin your browser to download a zipped SQL dump file. -
Checking Database Health: Access
check_health.phpto check the health and settings of the web and MySQL servers. -
Checking Database & Table Integrity: Open
check_integrity.phpto check the integrity of the database, including table row counts and encoding settings. -
Optimizing Database Tables: Open
optimize.phpto repair and optimize all tables in the database, improving performance and reducing disk space usage.
-
Security: These scripts can alter your database. Ensure they are adequately protected against unauthorized access (e.g., via .htaccess restrictions or IP whitelisting).
-
Testing: Test the scripts in a development environment before use in production to avoid data loss.
-
Permissions: The script files must have appropriate permissions to write to the necessary directories.
-
Permission Errors: If the scripts cannot read or write files, verify that the correct permissions are set on
DUMP_DIRandENCODED_DIR. -
Encoding Errors: Check the
ORIGINAL_ENCODINGandTARGET_ENCODINGsettings if the data does not appear as expected after conversion. -
Execution Timeouts: Adjust
MAX_EXECUTION_TIMEinsettings.phpif scripts timeout, especially when dealing with large databases.