Jump to content

script to import mysqldump file?


garyed

Recommended Posts

I am now trying to find a script to import a mysql dump file of a complete database.

If I do this in a Linux terminal it works fine.

mysql -h host -u user -p password  database < dumpfile.sql

Is it possible to put this command or something that will do the same thing in a php script? 

 

 

Link to comment
https://forums.phpfreaks.com/topic/196914-script-to-import-mysqldump-file/
Share on other sites

<?php
`mysql -h host -u user -p password  database < dumpfile.sql`

 

PHP has to have appropriate privileges though.

 

Wow, thanks that worked perfectly!

Now I can upload & import my databases from my home server to my web server with that simple script.

To be safe I'll delete the php file from the web server when I'm done & just  edit it on my home server. 

 

By the way does encasing a command in those ``(tildes) or whatever they're called make it act as though it was typed in a terminal because when I tried the exec() command it didn't work but those things sure did.   

 

 

 

 

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.