Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A library can dump mysql databases into a SQL file with limited permissions account and none-tables-locking.
PHP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
README

README

Introduction:

A library can be used to dump mysql database into a SQL file just like mysqldump does, but it never lock any tables. If the table is changed when dumping, the final data dumped with the library will be not as same as the origin database.

BTW: The mysql account only need the "SELECT" permission.

Usage: 

<?php
require '/path/to/pmdump/lib/PMDump.php';

$pdo = new PDO('mysql:dbname=test;host=localhost', 'mysqluser', 'pa$$W0rd');
$pmdump = new PMDump($pdo, array(

    # LIMIT number of rows per query
    'limit_per_select' => 500, 

    // add "DROP TABLE ..."
    'add_drop_table' => true,

    // add tables need ignored
    'excluded_tables' => array(),
), 'UTF8);
$pmdump->dump('database_name_here', '/path/to/file.sql');
?>

Importing the SQL file into a mysql server:
$ mysql -u root -p dbname < /path/to/file.sql
Something went wrong with that request. Please try again.