Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Mysql run script

Status
Not open for further replies.

CassidyHunt

IS-IT--Management
Jan 7, 2004
688
US
I am trying to upload a sql file and run it to replace the database, tables, and data.

What is the easiest way to do this?

Thanks

Cassidy
 
I would like to preface my post by saying what we are talking about is extraordinarily dangerous. If you don't have security airtight and if the server on which you can do this is exposed to hostile entities, you could find yourself in a world of hurt.


That said....

I would first have a script upload the file. See the PHP online manual chapter titled "Handling file uploads".

Then I would take the SQL script and pass it to the mysql command-line app by using PHP's Program execution functions.

Alternatively, you could write a PHP script to parse the SQL script query-by-query and execute each query in turn, but I figure why make yourself crazy?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top