PHP mysqldump不返回任何数据

时间:2016-06-10 15:17:16

标签: php mysqldump

我有这个脚本:

$command = "mysqldump --opt -h".DB_SERVER." -u".DB_USER." -p".DB_PASS." ".DB_NAME." | gzip > ".$filename;
system($command,$output);
echo $output;

看起来没问题,它会返回0.

其生成的文件包含:

-- MySQL dump 10.13  Distrib 5.1.73, for pc-linux-gnu (i686)
--
-- Host: localhost    Database: database_gourmet
-- ------------------------------------------------------
-- Server version   5.1.73-cll

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

没有表没有数据,是什么给出了?

1 个答案:

答案 0 :(得分:0)

使用PuTTY并回复Marc B建议我发现了问题,在这篇文章中有回复:

https://dba.stackexchange.com/questions/84370/why-mysqldump-is-returning-with-error-1143-couldnt-execute-show-table-status

我决定强制输出-f:

$command = "mysqldump -f -h".DB_SERVER." -u".DB_USER." -p".DB_PASS." ".DB_NAME." | gzip > ".$filename;