Jump to content

Restoring a .sql db backup using php


HaLo2FrEeEk

Recommended Posts

I have a .sql backup of my entire database, and I want to have a php page that will restore that file to a certain database, the query I am using is this:

 

mysql_select_db("test_forum");

$tableName  = 'test_forum';
$backupFile = 'test_forum.sql';
$query = "LOAD DATA LOCAL INFILE '$backupFile' INTO TABLE $tableName";
$result = mysql_query($query) or die("Failed: ".mysql_error());

 

I can see the problem in this code too, its right here:

 

INTO TABLE $tableName

 

I don't want to restore into a table, I want to restore the entire database.  Is there something I'm missing, or is this not possible?

Link to comment
https://forums.phpfreaks.com/topic/44543-restoring-a-sql-db-backup-using-php/
Share on other sites

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.