473,322 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Help with mysqldump...

Hello all.
Can anyone see why this snippet of code isnt dumping the databases using
mysqldump ?
All the credentials are correct (changed for the purpose of this post).

$host = "localhost";
$user = "root";
$pass = "password";
$database = "database";
$dbname = array ("1","2","3","4","5");
$savepath = "c:/inetpub/sqlbackup";
$date = date("mdy-hia");

$link = mysql_connect($host, $user, $pass) or die("Could not connect");
mysql_select_db($database) or die("Could not select database");

for ($i=0;$i<sizeof($dbname);$i++)
{
$filename = "$savepath/$dbname[$i]-$date.sql";
passthru("c:/mysql/bin/mysqldump --opt -h$host -u$user -p$pass $dbname[$i]
$filename");

}

mysql_free_result($result);
mysql_close($link);
Jul 17 '05 #1
4 2592
Mangina wrote:
Hello all.
Can anyone see why this snippet of code isnt dumping the databases using
mysqldump ?
All the credentials are correct (changed for the purpose of this post).

$host = "localhost";
$user = "root";
$pass = "password";
$database = "database";
$dbname = array ("1","2","3","4","5");
$savepath = "c:/inetpub/sqlbackup";
$date = date("mdy-hia");

$link = mysql_connect($host, $user, $pass) or die("Could not connect");
mysql_select_db($database) or die("Could not select database");

for ($i=0;$i<sizeof($dbname);$i++)
{
$filename = "$savepath/$dbname[$i]-$date.sql";
passthru("c:/mysql/bin/mysqldump --opt -h$host -u$user -p$pass $dbname[$i]
$filename");


}

mysql_free_result($result);
mysql_close($link);


I don't understand why "--opt" is in there.

Regards,

- Dan
http://blog.dantripp.com/
Jul 17 '05 #2
Checkyour mysql configuration (.my.cfg on unix). If you have
parameters set in [client] and not in [mysqldump] they take
precedience and you have problems. [client] seems to be a default set
of settings.

On Sun, 8 Feb 2004 20:03:21 -0900, Mangina <su*****@microsoft.com> wrote:


Hello all.
Can anyone see why this snippet of code isnt dumping the databases using
mysqldump ?
All the credentials are correct (changed for the purpose of this post).

$host = "localhost";
$user = "root";
$pass = "password";
$database = "database";
$dbname = array ("1","2","3","4","5");
$savepath = "c:/inetpub/sqlbackup";
$date = date("mdy-hia");

$link = mysql_connect($host, $user, $pass) or die("Could not connect");
mysql_select_db($database) or die("Could not select database");

for ($i=0;$i<sizeof($dbname);$i++)
{
$filename = "$savepath/$dbname[$i]-$date.sql";
passthru("c:/mysql/bin/mysqldump --opt -h$host -u$user -p$pass $dbname[$i]
$filename");

}

mysql_free_result($result);
mysql_close($link);

--
Michael Vore, W3CCV M-ASA [Ka8]; WHIRL, ABC; CAW, CW, AAW
http://mike.vorefamily.net/ohmywoodness <-You'll find items of interest here
Jul 17 '05 #3
Mangina wrote:
Hello all.
Can anyone see why this snippet of code isnt dumping the databases using
mysqldump ?
All the credentials are correct (changed for the purpose of this post).
I think I found a couple of things. See below. =)

$host = "localhost";
$user = "root";
$pass = "password";
$database = "database";
$dbname = array ("1","2","3","4","5");
$savepath = "c:/inetpub/sqlbackup";
$date = date("mdy-hia");

$link = mysql_connect($host, $user, $pass) or die("Could not connect");
mysql_select_db($database) or die("Could not select database");
Above, you're specifying the database names... so unless you're running
a query to get the db names, the two lines above aren't necessary. If
you want to dump all the databases, it'd be easier to use the
"--all-databases" flag with mysqldump than it would be to ask the db for
all the names first.

for ($i=0;$i<sizeof($dbname);$i++)
{
$filename = "$savepath/$dbname[$i]-$date.sql";
passthru("c:/mysql/bin/mysqldump --opt -h$host -u$user -p$pass $dbname[$i]
$filename");


}

mysql_free_result($result);
mysql_close($link);


Same basic comment as above. Those two lines probably aren't necessary.

I'm assuming that you're on a windows machine with IIS. =) Why else
would one have a "C:" in their path name... and want to put stuff in
"inetpub?. ;)

Your mileage may vary... but the following worked for me. Please note
that this *won't work* if safe mode is on in your php.ini file. Also,
my machine (Apache/XP) choked on the forward slashes in the path to
mysqldump, so I put in escaped backslashes. T'would be a different path
on *nix.

<?php

$host = "localhost";
$user = "user";
$pass = "password";
$dbnames = array ("db1","db2");
$savepath = "c:/inetpub/sqlbackup";
$date = date("mdy-hia");

foreach($dbnames as $dbname)
{
$filename = $savepath.$dbname."-".$date.".sql";
$execCmd = "c:\\mysql\\bin\\mysqldump.exe -h$host -u$user -p$pass
$dbname >> $filename";
exec($execCmd);
}

?>

Regards,

- Dan
http://blog.dantripp.com/
Jul 17 '05 #4
"Dan Tripp" <th*******@MyEMailAddress.com> wrote in message
news:a%******************@newssvr25.news.prodigy.c om...

<?php

$host = "localhost";
$user = "user";
$pass = "password";
$dbnames = array ("db1","db2");
$savepath = "c:/inetpub/sqlbackup";
$date = date("mdy-hia");

foreach($dbnames as $dbname)
{
$filename = $savepath.$dbname."-".$date.".sql";
$execCmd = "c:\\mysql\\bin\\mysqldump.exe -h$host -u$user -p$pass
$dbname >> $filename";
exec($execCmd);
}

?>


Thank you very much for your help. I will try this out later tonight and
post back.
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Thiko | last post by:
Hi We currently use mysqldump to dump all our db's in quick mode to one file, backup.sql. This file has come quite large. mysqldump -Aq -u root > /MySQL/backup/backup.sql I would now like...
1
by: Dino | last post by:
hello, every night i'm running a simple cronjob which created sql-dumps from serevral web applications using a syntax like this: mysqldump --add-drop-table -uuzzer -hmyhost -pmypw mydatabase...
7
by: Adam Smith | last post by:
Hope this is the right news group!! I did a server upgrade and at the same time did a mysql update from 4.0.12 to Ver 12.22 Distrib 4.0.16 mach1# mysql --version mysql Ver 12.22 Distrib...
0
by: mcstayinskool | last post by:
I'm trying to dump a bugzilla installation to a file, then restore it to a different database name (so as to test my db backup system). I use mysqldump to dump it to a file: # mysqldump -u root...
1
by: Greg.Harabedian | last post by:
I'll start off by saying I am using MySQL v4.0 and my question is...how do I get mysqldump to dump the actual binary values store in a blob? Here is an example: -- Create a test table create...
6
by: Todd Cary | last post by:
My client is using a shared server running MySQL 2.4, however the in house server is 4.1.12 with mysqldump 10.9. Is there a way to have the 10.9 version output a format that is fully compatible...
6
by: Robert Blackwell | last post by:
I want to make a scheduled task in windows to do a mysqldump. Someone gave me this .bat to run but I'm not able to get it to work. REM @echo off for /f "tokens=1" %%i in ('date /t') do set...
6
by: Antoni | last post by:
Hello, I'm trying to make a daily database backup. When executing "mysqldump - uxxx -pxxx database /home/backup/ddbb.sql -q &" the httpd server gets blocked and my site is "offline" for 30...
0
by: Pratchaya | last post by:
How can i dump (mysqldump) with skip query logging ? Now, when i run mysqldump. mysql log ( query log ) default running/keeping all in result mysqldump. It's possible ? to run mysqldump...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.