我在内部使用mysql server 5.5.33,在windows机器中使用IIS 6。 我正在使用这个PHP代码来创建dump .sql文件:
$command ="C:\\Program^ Files\\MySQL\\MySQL^ Server^ 5.5\\bin\\mysqldump -u root -pMYPASSWORD myDB >C:\mysites\my_source\mydir\myDB_dump.sql";
echo shell_exec("$command 2>&1 ; echo $?" );
然后我得到了一个文件myDB_dump.sql,我可以阅读:
mysqldump: Got error: 1049: Unknown database 'files\mysql\mysql' when selecting the database
-- MySQL dump 10.13 Distrib 5.5.33, for Win64 (x86)
--
-- Host: localhost **Database: Files\MySQL\MySQL**
-- ------------------------------------------------------
-- Server version 5.5.33-log
/*!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 */;
我不明白。数据库在那里,但似乎找不到它。 我做错了什么?
其他人有同样的问题,但未解决Copying issue with mysqldump和MYSQL DBDump Error message
2016年更新 这就是我所做的:
shell_exec("mysqldump -uroot -pPASSWORD --create-options -d $dbName > $pathName");//Where $dbName is the name of database and $pathName is "yourPath/mydump.sql"
shell_exec("C:\\xampp\\mysql\\bin\\mysqldump -uroot -pPASSWORD --create-options -d $dbName > $pathName");
现在这就是我得到的结果:
-- MySQL dump 10.13 Distrib 5.6.26, for Win32 (x86)
--
-- Host: localhost Database: drSET2014
-- ------------------------------------------------------
-- Server version 5.6.26
/*!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 */;
--
-- Table structure for table `address`
--
DROP TABLE IF EXISTS `address`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
...