使用 PHP 运行 `mysqldump` 生成的空文件 [英] Empty files generated from running `mysqldump` using PHP

查看:40
本文介绍了使用 PHP 运行 `mysqldump` 生成的空文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在运行时生成空文件

I keep getting empty files generated from running

$command = 'mysqldump --opt -h localhost -u username -p \'password\' dbname > \'backup 2009-04-15 09-57-13.sql\'';

command($command);

有谁知道这可能是什么原因造成的?我的密码中有奇怪的字符,但连接到数据库时工作正常.

Anyone know what might be causing this? My password has strange characters in it, but works fine with connecting to the db.

我运行了 exec($command, $return) 并输出了 $return 数组,它正在查找命令.我也用 mysqldump > 运行过它.file.sql 并且文件包含

I've ran exec($command, $return) and outputted the $return array and it is finding the command. I've also ran it with mysqldump > file.sql and the file contains

Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help

所以看起来命令正在起作用.

So it would seem like the command is working.

推荐答案

去除 -p 和密码之间的空格.如果它不起作用,请尝试从密码中删除引号

Remove the space between -p and the password. If it didn't work, try to remove the quotes from the password

来自 MySQL 文档:

如果您使用短选项形式 (-p),您不能在选项和密码之间有空格.

If you use the short option form (-p), you cannot have a space between the option and the password.

但是,使用 -h-u 选项留有空格是可以的

however, it is fine to have space with -h and -u options

这篇关于使用 PHP 运行 `mysqldump` 生成的空文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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