0

I have tried to backup my MySQL databases using PHP, yet when I set the path for the backup I receive another path when running the script.

this is my script:

$baseDir = 'backup/';
$db;
$table;
$server = $_SERVER['HTTP_HOST'] . substr($_SERVER['SCRIPT_NAME'],0,strrpos($_SERVER['SCRIPT_NAME'],'/'));

this is inside the backup function:

global $baseDir;
global $db;
global $server;
$backupFile = $server . "/$baseDir$db/$tab.sql";
$query = mysql_query("SELECT * INTO OUTFILE '$backupFile' FROM $tab");
if(!$query)
    echo "\t" .mysql_error() .PHP_EOL;
else
    echo " backuped." . PHP_EOL;

the path I get is: c:\wamp\bin\mysql\mysql5.1.36\data\localhost\db\backup\contact_keeper\accounts.sql with erroCode: 2 (can`t write/create).

1

1 Answer 1

2

SELECT ... INTO OUTFILE is limited to only CREATING a new file. It cannot overwrite an existing file as a security measure. As well, make sure that the account that MySQL is running under in Windows has write permissions on that ...\backup\contact_keeper directory. It may have only read/execute.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.