Jump to content

MySQL Database Backup


systech44

Recommended Posts

I wish to restore the data of tables of my database into Excel(.xls) or any other format. Below is my code.

 

<?php

mysql_connect("localhost","root","");
mysql_select_db("test");

$dbname    = "test";
$dbhost	= "localhost";
$dbuser	= "root";
$dbpass	= "";
$backupFile	= "restore";

$backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile";
system($command);

?>

 

There is no error. But I cannot see the output. Please tell me what is wrong with my code. Please rectify.

 

My environment is as below:

Windows XP

WampServer

 

Thanks a lot in advance.

Link to comment
https://forums.phpfreaks.com/topic/196953-mysql-database-backup/
Share on other sites

Note: When safe mode is enabled' date=' you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have ".." components in the path to the executable.[/quote']

 

With safe mode enabled' date=' the command string is escaped with escapeshellcmd(). Thus, echo y | echo x becomes echo y \| echo x.[/quote']

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.