<?php class DBManage { var $db; // 数据库连接 var $database; // 所用数据库 var $sqldir; // 数据库备份文件夹 var $record; // 换行符 private $ds = "n"; // 存储SQL的变量 public $sqlContent = ""; // 每条sql语句的结尾符 public $sqlEnd = ";"; /** * 初始化 * * @param string $host * @param string $username * @param string $password * @param string $thisatabase * @param string $charset */
Description: The volume file ends with _v1.sql
Function: Implement mysql database volume backup, select tables for backup, and implement single sql file and volume sql import
Usage:
1. Database backup (export)-------------------------------- ----------------------------
//They are the host, user name, password, and database name respectively. , database encoding
$db = new DBManage ('localhost', 'root', 'root', 'test', 'utf8' );
//Parameter: which table to back up ( Optional), backup directory (optional, default is backup), volume size (optional, default is 2000, which is 2M)
$db->backup ();
* ------2. Database recovery (import)--------------------------------------------- -----------------------
//They are the host, user name, password, database name, and database encoding
$db = new DBManage ('localhost', 'root', 'root', 'test', 'utf8' );
//Parameter: sql file
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
12 Jul 2016
Simple method to backup and restore MySql in php, restore mysql in php. How to simply back up and restore MySql in php, restore mysql in php This article describes the simple backup and restore method of MySql in php. Share it with everyone for your reference, the details are as follows: 1. Backup:
![How to Backup and Restore a Single MySQL Table?](https://img.php.cn/upload/article/001/246/273/173304115096896.jpg)
01 Dec 2024
How to Backup a Single Table in MySQLIn MySQL, the default behavior of the mysqldump utility is to back up an entire database. However, it is...
![How Can I Selectively Backup and Restore MySQL Tables?](https://img.php.cn/upload/article/001/246/273/173317285414043.jpg)
03 Dec 2024
Selective MySQL Table Backup and RestorationManaging vast databases often necessitates selective backups of individual tables. MySQL offers a...
![How to Efficiently Backup and Restore Multiple MySQL Databases?](https://img.php.cn/upload/article/001/246/273/173199234364375.jpg)
19 Nov 2024
Efficient Management of MySQL Database Backups: Export and Import Multiple Databases SimultaneouslyMaintaining regular data backups is crucial for...
![How Do I Backup and Restore a Single MySQL Table?](https://img.php.cn/upload/article/001/246/273/173300239270202.jpg)
01 Dec 2024
Backup and Restore of a Single MySQL TableBy default, the mysqldump utility backs up the entire database. However, it may be necessary to...
![](/static/imghw/down_right.png)
![](/static/imghw/taglogo.png)
Hot Tools
![PHP library for dependency injection containers](https://img.php.cn/upload/manual/000/000/001/5e2171bf3c005481.png)
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images
![](/static/imghw/taglogo.png)