Jump to content


Photo

Mysql dump - database backup


  • Please log in to reply
7 replies to this topic

#1 esport

esport
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 20 September 2006 - 10:17 PM

Hi guys,
Im trying to back my database up by using mysqldump and saving the results in a .sql file. However the file is returned with a few lines of text and not the sql of the tables.
Here is a snipet of the code i am using:

$LOCAL_DUMP_PATH = "db_back/";   
$FILENAME_PREFFIX = "sqldump";           

$filename = $FILENAME_PREFFIX.date("YmdHis").".sql";
 
$dump_cmd = "mysqldump -h'$DB_HOST' -u'$DB_USERNAME' -p'$DB_PASSWORD'";

$dump_cmd .= " --all-databases";

$dump_cmd .= " > $LOCAL_DUMP_PATH$filename"; 
exec($dump_cmd); 


Thanks
Daniel

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 September 2006 - 12:40 AM

You'd have to check the default options for mysqldump on the refman page... I'm not sure why you'd only get partial output.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 esport

esport
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 21 September 2006 - 12:49 AM

Not sure what the refman page is?

Is there anyother way to dump an entire mysql database into a text file?

D

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 September 2006 - 12:50 AM

Well, you could use SELECT INTO OUTFILE, but mysqldump is better...
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 esport

esport
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 21 September 2006 - 12:56 AM

This is the output i get:

-- MySQL dump 10.10
--
-- Host: localhost    Database:
-- ------------------------------------------------------
-- Server version 4.1.21

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

--
-- Current Database: `IT2002_actiond`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `IT2002_actiond` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `IT2002_actiond`;


#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 September 2006 - 01:23 PM

Take a look here: http://dev.mysql.com.../mysqldump.html -- I'm not sure why you're not getting any data output.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 esport

esport
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts

Posted 22 September 2006 - 12:28 AM

I had a look at this page before, it didn't realy help as in why it is not producing an output. Its really doing my head in as im sure im doing everything right,.

D

#8 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 22 September 2006 - 03:44 AM

Could it be permission problems?
Are you using InnoDB tables?
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users