
05-22-11, 23:57
|
|
BOD Member
|
|
Join Date: Jun 2010
Posts: 175
|
|
PHP script to import MySQL database
PHP script to import MySQL database
We can use a script to import mysql database which can be easier and time consuming. All we need to do is create a phpfile say for example import.php and place it in our public_html folder so that it can be accessible.
Once it is created we just need to edit the file and paste the following code in it:
<?php
passthru("nohup mysql -u USERNAME -pPASSWORD DBNAME < dump.sql");
?>
Make sure to replace the USER,PASSWORD and DBNAME with the database details in which you want to import the dumped file, and dump.sql is the file you want to import. Make sure you give the correct and complete path to the dump.sql file.
Once all done open your browser and type in the URL for update.php file, e.g. http://yourdomain.com/update.php.
And finally to test if it has been imported successful, just log in to your phpMyAdmin tool from your cPanel and review the database.
__________________
Carol.P
|