dg/mysql-dump

MySQL database dump.

Maintainers

👁 david@grudl.com

Package info

github.com/dg/MySQL-dump

pkg:composer/dg/mysql-dump

Statistics

Installs: 3 105 216

Dependents: 13

Suggesters: 0

Stars: 210

v1.7.0 2026-05-18 00:49 UTC

Requires

  • php: >=7.1

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 257d0c2c0ed4415330912456d252f2f4253496cc

mysql

This package is auto-updated.

Last update: 2026-06-01 15:11:51 UTC


README

This is a backup utility used to dump a database for backup or transfer to another MySQL server. The dump typically contains SQL statements to create the table, populate it, or both.

It requires PHP 8.2 or later.

Usage

Create MySQLi object and pass it to the MySQLDump:

$db = new mysqli('localhost', 'root', 'password', 'database');
$dump = new MySQLDump($db);

You can optionally specify how each table or view should be exported:

$dump->tables['search_cache'] = MySQLDump::DROP | MySQLDump::CREATE;
$dump->tables['log'] = MySQLDump::NONE;

Available flags: NONE, DROP, CREATE, DATA, TRIGGERS, ROUTINES, and ALL (all of the above). ROUTINES is read from $dump->tables['*'] and controls export of stored functions, stored procedures, and scheduled events at the database level. The DEFINER= clause is stripped from exported routines so the dump imports cleanly under any user.

Then simply call save() or write():

$dump->save('export.sql.gz');

Import dump from file to database this way:

$import = new MySQLImport($db);
$import->load('dump.sql.gz');

If you like it, please make a donation now. Thank you!