如何使用查询备份MySQL数据库? [英] How to backup MySQL database using Query?

查看:402
本文介绍了如何使用查询备份MySQL数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何使用查询来备份MySQL数据库,就像我们可以使用以下查询来备份MS-SQL一样.

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

查询:

backup database DATABASENAME to disk = 'PATH'

推荐答案

使用mysqldump-php纯PHP解决方案来复制mysqldump的功能

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');
        ?>

也访问此链接 GitHub

这篇关于如何使用查询备份MySQL数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆