3 Easy ways to import large MySQL database
Apr 16, 2008
Author: Gio | Filed under: Review, other, phpmyadmin
From time to time, we get into situation when we would like to know just how-to import big database in phpmyadmin?
The problem is that most of the php.ini - the PHP configuration file on server (that is your host, if you are on shared hosting) is limiting maximum file upload size to 2mb.
In that case casual BROWSE>UPLOAD model fails to work with phpmyadmin, so we need to seek altarnatives. Let’s see what we can do:
- Notepad Way - First of all we could just open sql backup file with Notepad and just copy-paste code blocks to phpmyadmin SQL function and execute it one-by-one. But what to do if database is way too large?
- Sever-side Way - If you’re on dedicated server the quick fix would be just to rise maximum file upload limitation, and maximum execution time, so importing will not stop in the middle of the process. To do that, you have to first find php.ini file, if you are on linux just fire up SSH and type:
locate php.iniThat will output location of your php.ini file, just go there, open it and find these variables:
- upload_max_filesize - maximum file size that php scripts can accept (phpmyadmin in this case)
- max_execution_time - maximum time php scripts can process one request (phpmyadmin’s database importing process in this case)
- memory_limit - optionally you might need to rise this one too.
if you dont have these variables, simply add them by typing and give them desired sizes.
Save it and restart apache service:
service httpd start
- Script Way - But what can we do if you’re on shared hosting and dont have access to php.ini file? In that case nice and nifty script BigDump will help, which was written by Alexey Ozerov specially for importing large databases.
- First of all, go and download your copy here: http://www.ozerov.de/bigdump.zip
- unzip it and upload both bigdump.php and your_database.sql to the same directory via ftp (Both bigdump.php and your_database.sql MUST be uploaded with ASCII (text) mode)
- open bigdump.php via any editor and edit your system variables. Save it.
- Acces via Browser your bigdump.php file, like these: http://www.somesite.com/somedirectory/bigdump.php
- Now select the file to be imported from the listing of your working directory
- Get cola or something and wait DO NOT CLOSE BROWSER WINDOW UNTILL IMPORTING IS FINISHED
- Remove bigdump.php and your_database.sql from server
- Enjoy
You can get more info on using BigDump script, also troubleshooting it, help, FAQ, etc. on it’s official site [HERE]
Leave a reply