Mohiyo Deen Mohiyo Deen - 2 months ago 10
MySQL Question

How to backup MySQL database using Query?

How can we backup MySQL database using Query, like we can backup MS-SQL using following Query.

Query:

backup database DATABASENAME to disk = 'PATH'

Answer

Use mysqldump-php a pure-PHP solution to replicate the function of the mysqldump

 <?php
    require('database_connection.php');
    require('mysql-dump.php')
    $dumpSettings = array(
        'include-tables' => array('table1', 'table2'),
        'exclude-tables' => array('table3', 'table4'),
        'compress' => CompressMethod::GZIP, /* CompressMethod::[GZIP, BZIP2, NONE] */
        'no-data' => false,            
        'add-drop-table' => false,      
        'single-transaction' => true,   
        'lock-tables' => false,        
        'add-locks' => true,            
        'extended-insert' => true      
    );

    $dump = new MySQLDump('database','database_user','database_pass','localhost', $dumpSettings);
    $dump->start('forum_dump.sql.gz');
        ?>

also visit this link GitHub