Restoring A MySQL Database Via PHP
Posted: Mon Apr 29, 2002 3:59 am
Perhaps it is due to the late hour and my readiness for slumber, but I am encountering some difficulty with a PHP program to restore a MySQL database.
This works from the command line (with "mypassword", "mydatabase", and "myfile" replaced by the real things, of course):
So why does this not work?
I even tried passing the exact string that works from the command line, but that did not work either.
I suppose I could open the file, parse it, then send it to MySQL as a query, but it seems that this simple, common action should be accomplished much more quickly.
Is it just me or is mysql_restore() an obvious choice for a future standard PHP function? I have thought of a few others as well. Hmm... I might look into writing some myself then contributing them, but not until after I figure this out. Heh.
This works from the command line (with "mypassword", "mydatabase", and "myfile" replaced by the real things, of course):
Code: Select all
mysql --password=mypassword mydatabase < myfileCode: Select all
if (system("mysql --password=$Password $Database < $File")) {...I suppose I could open the file, parse it, then send it to MySQL as a query, but it seems that this simple, common action should be accomplished much more quickly.
Is it just me or is mysql_restore() an obvious choice for a future standard PHP function? I have thought of a few others as well. Hmm... I might look into writing some myself then contributing them, but not until after I figure this out. Heh.