Home > Database > Mysql Tutorial > MYSQL的备份还原(PHP实现)_MySQL

MYSQL的备份还原(PHP实现)_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:34:55
Original
855 people have browsed it

bitsCN.com

手把手教你实现MYSQL的备份还原

在文章最后会附上代码,但是建议大家认真从头看完。代码不重要,实现的思路才是重点。

示例代码用我比较熟悉的PHP,当然你看完并理解了其中的思路,相信你也可以快速地用你熟悉的语言自己写出来。

一、新建dbBackup类,设置默认参数。

class dbBackup {    public $host='localhost';    //数据库地址    public $user='root';    //登录名    public $pwd='';    //密码    public $database;    //数据库名    public $charset='utf8';    //数据库连接编码:mysql_set_charset}
Copy after login

二、添加数据库连接function。

    /**     * 连接数据库 ...     */    function db() {                $con = mysql_connect($this->host,$this->user,$this->pwd);        if (!$con){            die('Could not connect');        }                $db_selected = mysql_select_db($this->database, $con);        if (!$db_selected) {            die('Can/'t use select db');        }                mysql_set_charset($this->charset);  //设置编码                return $con;    }
Copy after login

 

三、查询数据库表集合

    /**     * 表集合 ...     */    function tblist() {        $list=array();                $rs=mysql_query("SHOW TABLES FROM $this->database");        while ($temp=mysql_fetch_row($rs)) {            $list[]=$temp[0];        }                return $list;    }
Copy after login

 

编辑中.................

bitsCN.com
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template