1

I am using mysql server 5.5.33 inside and a IIS 6 in a windows machine. I am using this php code to create a dump .sql file:

$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 $?" );

Then I got a file myDB_dump.sql where I can read:

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 */;

I do not understand. The database is there, but it seems that it is not found. What am I doing wrong?

Others had the same issue, but not solved Copying issue with mysqldump and MYSQL DBDump Error message


Update 2016 This is what I did:

  1. Set the environment variables for MySQL. Linux or Windows.
  2. After sit , use this code shell_exec("mysqldump -uroot -pPASSWORD --create-options -d $dbName > $pathName");//Where $dbName is the name of database and $pathName is "yourPath/mydump.sql"
  3. Or try the code with the full path to mysqldump if you where not able to set environment variables. Example: If you have MySql inside xampp, the full path will be like this: shell_exec("C:\\xampp\\mysql\\bin\\mysqldump -uroot -pPASSWORD --create-options -d $dbName > $pathName");

And now this is what I got as result:

-- 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 */;

...
Community
  • 1
  • 1
IgorAlves
  • 5,086
  • 10
  • 52
  • 83
  • Hi, I realize this post is from nearly a year ago, but did you ever figure this out? I'm now having the same issue where mysqldump is interpreting the export-to filename as a database name. Any help appreciated! – S.A Feb 26 '16 at 18:39
  • I updated the question. Hope it can help you. – IgorAlves Feb 26 '16 at 19:51

0 Answers0