Web Hosting Talk







View Full Version : mysqldump


Dominic
10-25-2001, 11:26 PM
How to use mysqldump in php?
I try

<?
`mysqldump -utest -ptest --opt data>/data.sql`;
?>

But this not work...:rolleyes:

Thanks!

(SH)Saeed
10-25-2001, 11:40 PM
mysqldump -uUsername -p Databasename >./file.txt

When you run this, it will ask you for your password and then dump everything into the file "file.txt" in the same directory where you run the command.

I think you can put the password in the command line as well..

mysqldump -uUsername -pPassword Databasename >./file.txt

JTY
10-25-2001, 11:46 PM
To run it via PHP you need to use a system call...

e.g.

system("mysqldump -uUsername -pPassword Database >out.sql");

of course you need to put the full path to mysqldump and the full path to where you want the file dumped...

Dominic
10-26-2001, 12:06 AM
Thanks...:blush:

Dominic
10-26-2001, 01:54 AM
Just try the script for many many times...
It work well with the shell...but not work at the browser...:rolleyes:

<?
system("/usr/bin/mysqldump databasename -u username -ppassword >path/to/dump/file.sql");
?>

What wrong with my script?
Thanks!

ffeingol
10-26-2001, 07:36 AM
I believe you have the parameters in the wrong order:


<?
system("/usr/bin/mysqldump databasename -u username -ppassword >path/to/dump/file.sql");
?>


Should be:


<?
system("/usr/bin/mysqldump -u username -ppassword databasename >path/to/dump/file.sql");
?>


You might also want to check the return value of the system call.

Frank

Dominic
10-26-2001, 09:26 AM
Hmm...just check the error log...:)
If I run the php in a browser,
and a file.sql is already here,
the php cannot cover the old one...
I should have another filename.

Dominic
10-26-2001, 09:32 AM
Or chmod the old database to 666...;)