Web-en

Import a large SQL file in PHPMyAdmin

If you are wondering how to be able to import a larger SQL file in PHPMyAdminicon[1], the solution is pretty easy, to allow it through the standard phpMyAdmin sql import – which can also be used to import a csv in phpMyAdmin, or even to import an OpenDocument Spreadsheet in phpMyAdmin, simply by changing the input format in import menu.

Your limitation (for example, it can be 2Mb with XAMPPicon (Fig 1)) is most likely due to your php.ini configuration.

PHPMyAdmin with 2Mb limit MySQL import
Fig 1 : PHPMyAdmin with 2Mb limit MySQL import

Simply open it – for example, with XAMPPicon[2], by selecting the Apache Config menu entry “php.ini” (Fig 2). Search for the following values in your php.ini file : post_max_size, upload_max_filesize, and memory_limit.

XAMPP open the php.ini configuration file
Fig 2 : XAMPP open the php.ini configuration file

In case they are not in sync, your maximum allowed upload file size will be limited by the smaller value, keeping in mind the memory limit should be higher than the two other values, as memory will be needed to store and process the data, not counting other server activities.

These were the default values on my local server :

post_max_size=8M
upload_max_filesize=2M
memory_limit=128M

A possibility – to customize to your own needs – can be to update them to following values (Fig 3) :

PHPMyAdmin with 128Mb limit MySQL import
Fig 3 : PHPMyAdmin with 128Mb limit MySQL import

post_max_size=128M
upload_max_filesize=128M
memory_limit=1024M

Don’t forget, after applying these changes, to restart your Apacheicon[3] server – on XAMPPicon[2], stop it (Fig 4) and start it again (Fig 5) (Fig 6) (Fig 7).

Stop XAMPP Apache server
Fig 4 : Stop XAMPP Apache server
Start XAMPP Apache server
Fig 5 : Start XAMPP Apache server
XAMPP Apache server starting
Fig 6 : XAMPP Apache server starting
XAMPP Apache server started
Fig 7 : XAMPP Apache server started

Just to show an example, in case you update only one value, for example upload_max_filesize, and end up with the following values (Fig 8) :

PHPMyAdmin with 8Mb limit MySQL import
Fig 8 : PHPMyAdmin with 8Mb limit MySQL import

post_max_size=8M
upload_max_filesize=128M
memory_limit=128M

Even though you have setup the maximum filesize to a higher value, it won’t work as the maximum posting size is lower.

PHPMyAdminicon[1] will only allow you 8Mb.

Links and credits

  • [1] – PHPMyAdmin : A tool written in PHP intended to handle the administration of MySQL over the WWW. – www.phpmyadmin.net
  • [2] – XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl – www.apachefriends.org
  • [3] – Supports the development of a number of open-source software projects, including the Apache web server – www.apache.org

Images