使用 PHP 在 WAMP 服务器上进行 MySQL 转储 [英] MySQL dump on WAMP server using PHP

查看:47
本文介绍了使用 PHP 在 WAMP 服务器上进行 MySQL 转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PHP 文件转储 mysql 数据库.我使用的是 Windows 7 操作系统.

I am trying to dump the mysql database using a PHP file. I am using windows 7 OS.

但我总是出错;这是我的代码

but I am always getting error; This is my code

$user='root';
$pass='mypassword';
$host='localhost';
//$sql_file='db_backup.sql';
$cmd = "e:\\wamp\\bin\\mysql\\mysql5.6.12\\bin\\mysqldump -h$host  -u$user -p$pass hospitalerp > db_backup.sql";
exec($cmd, $output, $return);
if ($return != 0) { //0 is ok
    die('Error: ' . implode("\r\n", $output));
}

echo "dump complete";

任何建议将不胜感激.谢谢.

Any suggestion will be greatly appreciated. Thanks.

推荐答案

好的,我找到了解决方案,可能有人觉得有用.

Ok I found the solution, may someone find it useful.

$user='root';
$pass='mypassword';
$host='localhost';

$cmd='e:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump --user='.$user.' --password='.$pass .' --host=localhost hospitalerp > db_backup4.sql';
//var_dump($cmd);exit;
exec($cmd, $output, $return);
if ($return != 0) { //0 is ok
    die('Error: ' . implode("\r\n", $output));
}

echo "dump complete";

这篇关于使用 PHP 在 WAMP 服务器上进行 MySQL 转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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