473,544 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_resu lt($result);
mysql_close($li nk);
Jul 17 '05 #1
4 2600
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_resu lt($result);
mysql_close($li nk);


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*****@micros oft.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_resu lt($result);
mysql_close($li nk);

--
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_resu lt($result);
mysql_close($li nk);


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($dbname s as $dbname)
{
$filename = $savepath.$dbna me."-".$date.".s ql";
$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*******@MyEM ailAddress.com> wrote in message
news:a%******** **********@news svr25.news.prod igy.com...

<?php

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

foreach($dbname s as $dbname)
{
$filename = $savepath.$dbna me."-".$date.".s ql";
$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
493
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 to split the mysqldump so that the output comprises of several files of less than 2 gigabytes each. Does anyone know the mysqldump options that...
1
1589
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 table1 table2 table3 > dumpme.sql after this, the sql-dump is packed together with the pages of the website, creating a whole backup-archive.
7
7400
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 4.0.16, for portbld-freebsd4.9 (i386) I attempted to restore the DB with
0
2252
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 -p<passwd> (misc. options) bugs > bugs.sql Then try to restore it to an empty DB, "foobar" with this command # mysql -u root -p<passwd> foobar <...
1
4667
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 table dummy(col1 blob); -- Next insert a null ascii character (0) insert into dummy values (char(0)); -- To verify there is actually something there...
6
5960
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 with 2.4? Some of the CREATE TABLE statements in 10.9 are not accepted by 2.4. Currently, I am not using any of the switches in creating the...
6
30078
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 DATE_DOW=%%i for /f "tokens=2" %%i in ('date /t') do set DATE_DAY=%%i for /f %%i in ('echo %date_day:/=-%') do set DATE_DAY=%%i for /f %%i in ('time...
6
6151
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 minutes. I also tried using mysqlhotcopy, but with no success since it fails with error: "DBD::mysql::db do failed: Not unique table/alias: 'comments' at...
0
2916
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 without query logging ? ( when i run mysqldump .. i 'm not need to keey query log ) Thank you very much.
0
7437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7373
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7389
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5306
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3427
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.