PHP/MySQL Dump to File
So I want to create a php script that will use the MySQL dump feature to dump my database (and specified tables) to a file that I will create on the fly with php. Is this possible? I did some research but could not find anything.
Any help is appreciated, thanks.
PS I know I can just use PHPMyAdmin to dump the contents of my database, but I am trying to create this script, so it will automatically make a file on the server and save the dump contents.
$filename= "backupname-$datestamp.sql.gz"; // The name path of the dump file
$command = "mysqldump -u $dbuser --password=$dbpwd $dbname | gzip > $filename";
$result = passthru($command);
would doing it this way require me to have the file already created on the server? I wanted to create the file automatically.
Also in the MySQLDump command, how do I specify which tables to dump. I woulld like to ignore some tables.
no you will not have to have the file already on the server. it will automatically create it in the directory.
You could then ftp that file or email it if it was small or whatever you want to do with it...
so i try this:
and i see that the file is created, but the file is empty. is there an error log I can look up?
$command = "mysqldump dbname orders > file.sql";
Am I doing this wrong? I tried it with the commands for user and password but that didnt work either.
any reason why I the file is created but empty? it looks to me like I am not getting connected to the database, but i do not get any error messages. is there an mysql_error log somewhere?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)