aberns
asked on
Setting up a backup routine with Select Into OUTFILE or alternative?
Hello,
I am trying to create a php backup routine for my MySQL databases that I can run as CRON jobs a few times a day.
Here is what I have so far:
The error I get is:
Access denied for user 'database'@'%' (using password: YES)
I have set the directorypath folder permissions to 777 and created the file name in advance.
Can you provide assistance with this method or suggest an alternate script? Thank you very much.
I am trying to create a php backup routine for my MySQL databases that I can run as CRON jobs a few times a day.
Here is what I have so far:
The error I get is:
Access denied for user 'database'@'%' (using password: YES)
I have set the directorypath folder permissions to 777 and created the file name in advance.
Can you provide assistance with this method or suggest an alternate script? Thank you very much.
connect stuff...
$tableName = 'SampleTable';
$backupFile = $_SERVER['DOCUMENT_ROOT'].'/directorypath/Sampletable.sql';
$query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
$result = mysql_query($query) or die(mysql_error());
mysql_close($link);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You may want to check this out:
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
It's a MySQL tool to run backups and it can be scheduled as a cron job.
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
It's a MySQL tool to run backups and it can be scheduled as a cron job.
ASKER
For the link you sent, it looks like I need shell access? The only access I have is via PHPMyAdmin or by writing a PHP script.
I was actually looking into this solution:http://www.sematopia.com/?p=61
I was actually looking into this solution:http://www.sematopia.com/?p=61
That is basically a PHP shell using exec() to use the mysqldump command.
If you have permission to exec() it looks like a reasonable solution. Give it a go :)
If you have permission to exec() it looks like a reasonable solution. Give it a go :)
ASKER