php 通过网页的方式备份和还原mysql数据库
最近上网找了一些关于备份mysql数据库的方法,主要就是通过网页的方法导出数据库的sql 文件,找到个不错的代码,但发现中文导出会乱码,于是稍微修改了一下,下面是备份的代码
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库备份</title>
<link href="user/input.css" mce_href="user/input.css" rel="stylesheet" type="text/css" />
</head>
<?
global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;
$mysqlhost="localhost:3306"; //host name
$mysqluser="root"; //login name
$mysqlpwd="zgqyb"; //password
$mysqldb="zgqyboa"; //name of database
include("mydb.php");
$d=new db($mysqlhost,$mysqluser,$mysqlpwd,$mysqldb);
/*--------------界面--------------*/if(!$_POST['act']){/*----------------------*/
$msgs[]="服务器备份目录为F:\\SQLbak";
$msgs[]="对于较大的数据表,强烈建议使用分卷备份";
$msgs[]="只有选择备份到服务器,才能使用分卷备份功能";
show_msg($msgs);
?>
<form name="form1" method="post" action="backup.php">
<table width="99%" border="1" cellpadding='0' cellspacing='1'>
<tr align="center" class='header'><td colspan="2">数据备份</td></tr>
相关文档:
引用文件的方法有2种:
1、require
require("conn.php"); 一般放在页面的第一行,做为该页执行的一部分,首先执行require内的conn.php 然后再执行下面的代码
2、include
include("header.php");当程序到达这里的时候才会执行include的 header.php ......
<?
include 'conn.php';
$_pagenob=10; //每页规定的信息数目
//获取当前页
if(isset($_GET["page"]))
{
$_page = intval( $_GET['page'] );
}
else
{
$_page=1;
}
//查询数据总数
$_query="select count(*) as acount from news";
$_result=mysql_query($_query);
$_row=mysql_fetch_row($_result);
......
报错:
/tmp/ccBBJEB8.o: In function `ping_sql':
pingsql.c:(.text+0x7c): undefined reference to `mysql_init'
pingsql.c:(.text+0xe1): undefined reference to `mysql_real_connect'
pingsql.c:(.text+0xff): undefined reference to `mysql_close'
pingsql.c:(.text+0x119): undefined reference to `mys ......
从http://hackmysql.com/mysqlsla下载mysqlsla,当前最新版为:2.03
tar zxvf mysqlsla-2.03.tar.gz
cp mysqlsla-2.03/bin/mysqlsla /usr/local/bin
如果提示“Can’t locate DBI.pm”,执行以下命令
yum install perl-DBI perl-DBD-MySQL -y
这时就可以使用mysqlsla了,用法如下
mysqlsla -lt slo ......