使用PHP恢复MySQL数据库 [英] MySQL database restore using PHP

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

问题描述

我正在尝试按以下方式恢复MySQL转储:

I'm trying to restore MySQL dump created the following way:

$file = '/path/to/file.sql';
exec('mysqldump -u '.DB_USER.' -p'.DB_PASS.' '.DB_NAME.' > '.$file);

上面按预期创建转储,然后恢复我正在尝试使用以下内容: / p>

the above creates the dump as expected, then to restore I'm trying to use the following:

$file = '/path/to/file.sql';
exec('mysql -u '.DB_USER.' -p'.DB_PASS.' '.DB_NAME.' < '.$file);

但由于某种原因它没有做任何事情。

but for some reason it doesn't do anything.

请注意,常量包含相关的数据库连接参数。

Please note that the constants contain the relevant database connection parameters.

知道我做错了吗?

推荐答案

使用 mysql -e'source $ file'而不是重定向

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

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