Jump to content

Backup MySQL PHP script


kool_samule

Recommended Posts

Hi guys,

 

I have a simple script that backup the contents of a database and place the file on the server.

The problem is that this script works fine on my Apache server, but not on the IIS server (HTTP 500 error).

Script:

<?php
$backupFile = "../DBJobs_" . date("Y-m-d");
$command = "mysqldump --opt -h localhost -u (user) -p(password) dbjobs > $backupFile.sql";
system($command);

if ($command) {
$mess = "<p>Backup file created!</p>";
}
else {
  $mess = "<p>There was a problem with the backup routine.</p>";
}
?>

 

Do I have to change the $command variable or the system function?

 

Any help would be very appreciated.

Link to comment
https://forums.phpfreaks.com/topic/175496-backup-mysql-php-script/
Share on other sites

Hi Bricktop,

 

MySQL is installed and working, I can connect to it fine, do all the usual stuff, add, edit and delete records.

 

On my development server (Apache) the $command works fine and runs, after migrating to the IIS server (and editing the connection settings), I can't seem to get this to work.

Hi kool_samule,

 

Have you correctly configured your PHP variables so it knows where MySQL is installed?

 

Have a look at http://www.artfulsoftware.com/php_mysql_win.html for more information.  Scroll to the bottom of the page and read the "Configuring PHP and MySQL under IIS  section.

 

Hope this helps.

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.