PHP BSD-3-Clause

MySQL-dump

MySQL Dump Utility

D

dg

Dernière activité 31 juil. 2026
dg/MySQL-dump

210

étoiles

47

forks

4

issues ouvertes

backupmysql-dump-utilityphp

Ce README est souvent en anglais.

MySQL Dump Utility

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 and triggers 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!

Projets similaires

Dump the contents of a database

PHPdatabasedumpmysql
Sspatie
1,2 k étoiles159

PHP version of mysqldump cli that comes with MySQL

PHPdatabasehhvmlinux
Iifsnop
1,3 k étoiles290

A tool for creating configurable dumps of large MySQL-databases.

PHPdatabasemysqlphp
Wwebfactory
194 étoiles28