How to import large mysql database fast and secure way using php ? Why we need to use this php script ?
We are not successful full large database export or import using PhpMyAdmin and there take a more time for that operation so.
Follow below steps and import or export large mysql database using php shell script.
How to import :
- First need database .sql file(Exported from your local PC or from other source)
- Need target database name with username and password for import database.
- Create one import.php file and write below code
<?php //Mysql command use for access database and import var_dump(shell_exec("mysql -u username -pPassword NewDatabaseName < 9code.info_db.sql)); echo "Database import DONE"; //Now you can see your updated database ?>
- Now need to upload 9code.info_db.SQL file in where you created import.php file.
- Now run this script file like https://9code.info//import.php
How to Export Database:
- Need database name which is you need to import and his username and password for export .
- Create one export.php file and write below code
<?php //Mysqldump command use for export each dump of database var_dump(shell_exec("mysqldump -u username -pPassword myLivedatabase > exported_new.sql")); echo "Database exporting ...."; //Please wait some time and then just you need to download that file from where your export.php file location //like : www.9code.info/exported_new.sql //See your sql script file ?>
- Now need to upload 9code.info_db.SQL file in where you created import.php file.
- Run above script file for export database https://9code.info/export.php
I hope working in your practical. Let me know if you need more clarification or other issue.
Thanks a lot
Leave a Reply