garyed Posted March 29, 2010 Share Posted March 29, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/196914-script-to-import-mysqldump-file/ Share on other sites More sharing options...
nicholasstephan Posted March 29, 2010 Share Posted March 29, 2010 you can do the same thing using phpMyAdmin (www.phpmyadmin.net). Quote Link to comment https://forums.phpfreaks.com/topic/196914-script-to-import-mysqldump-file/#findComment-1033809 Share on other sites More sharing options...
Mchl Posted March 29, 2010 Share Posted March 29, 2010 <?php `mysql -h host -u user -p password database < dumpfile.sql` PHP has to have appropriate privileges though. Quote Link to comment https://forums.phpfreaks.com/topic/196914-script-to-import-mysqldump-file/#findComment-1033815 Share on other sites More sharing options...
andrewgauger Posted March 29, 2010 Share Posted March 29, 2010 I dont think there is a space between -p and password. -ppassword if your password is password. Threw me for a loop for a long time. Quote Link to comment https://forums.phpfreaks.com/topic/196914-script-to-import-mysqldump-file/#findComment-1033819 Share on other sites More sharing options...
garyed Posted March 30, 2010 Author Share Posted March 30, 2010 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/196914-script-to-import-mysqldump-file/#findComment-1033866 Share on other sites More sharing options...
Mchl Posted March 30, 2010 Share Posted March 30, 2010 http://php.net/manual/en/language.operators.execution.php Quote Link to comment https://forums.phpfreaks.com/topic/196914-script-to-import-mysqldump-file/#findComment-1033969 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.