PHP Classes

PHP MySQLDump Table Chunks: Dump MySQL tables in chunks of limited size

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 314 All time: 7,257 This week: 115Up
Version License PHP version Categories
mysql-chunk-dump 1.0BSD License5PHP 5, Databases, Systems administration
Description 

Author

This class can dump MySQL tables in chunks of limited size.

It can query a given MySQL database table to get statistics of its size.

Then the class calls the mysqldump program multiple times to output the SQL INSERT statments to multiple files, each one with a limited number of rows.

Innovation Award
PHP Programming Innovation award nominee
November 2014
Number 5


Prize: One downloadable copy of PhpED Professional
One common way to generate backups of a database is to dump to a file a list of SQL statements that can be used later to recreate each database table. That is what the mysqldump does for generating dumps of MySQL databases.

Tables with many records may generate large database dump files.

This class implements a solution to avoid generating database dump files that exceed a given limit in size.

It queries a given MySQL database to get statistics of the size of each database table. Then it runs the mysqldump program as many times as necessary to generate separate database dump files of each database table, so each has a limited number of rows.

This way it assures that each database dump file does not exceed a given size limit.

Manuel Lemos
Picture of Ovidiu Lesei
Name: Ovidiu Lesei is available for providing paid consulting. Contact Ovidiu Lesei .
Classes: 5 packages by
Country: Romania Romania
Age: 41
All time rank: 132635 in Romania Romania
Week rank: 314 Up2 in Romania Romania Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php
 
require_once './mysqlDump.php';

$mysqli = new mysqli('localhost','root','','dataBase');

$params['mysqli'] = $mysqli;
$params['database'] = 'dataBase';
$params['tableName'] = 'table';
$params['chunkPath'] = './';
$params['mysqlDump'] = '/usr/local/mysql/bin/mysqldump'; //Or mysqldump
$params['chunkSize'] = '1572864'; //~1.5 Mega
$params['username'] = 'root';
$params['password'] = '';


$dump = new mysqlDump($params);
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example
Plain text file mysqlDump.php Class Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:314
This week:0
All time:7,257
This week:115Up