Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql dumb 2

Status
Not open for further replies.

estrellas

Programmer
Jul 16, 2004
48
US
hi guys -
i'm trying to create a mysql dump of my databases ... and i'm not quite sure how to do it. the command i'm using is this:
PHP:
 mysqldump -p -u root database > database.sql;
it says that i have an error in my syntax.
do you know why and do you know the proper format to do a mysql dumb that will work?

thanks much in advance - i really appreciate it :)
cheers :)

-------
 
If you are trying to do this from php, you'll need to run it as a system command , you'll need to look up and understand the implications of system() or exec().

You'll also need to understand the syntax required for mysqldump, and its many options.
If you are trying to run this command on one server where the mysql server is on a completely different server, you will need the --quick option so that you don't kill the dumping server by filling its memory.


heres one I did for the hell of it :)
Code:
<?php
$host="localhost";
$user="root";
$pass="";
$database='mysql';
$table='user';

$outfile=$database.".".$table.".sql";
$cmd="mysqldump --host=$host --user=$user --password=$pass --complete-insert $database $table > $outfile";

        system($cmd,$retval);

if($retval > '0'){

        echo "$retval - something wrong";

}else{

        echo "Dump completed<br>";
echo "<a href=$outfile>$outfile</a>";

}
?>


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top