When doing website development with MySQL, we often need to do database backup and restore. For website, the data in database will grow quickly, so when we back up the database, the size of the generated sql file may be over 80MB which is the max allowed size when we want to import a sql file for restoring our database using phpMyAdmin. To workaround this limit, we need to review the documentation of phpMyAdmin. Fortunately, I found an online article written by David Pratt which gave us a very simple solution to this problem.
Find the config.inc.php file located in the phpmyadmin directory. In my case it is located here:
1
|
C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php |
Find the line with $cfg['UploadDir'] on it and update it to:
1
|
$cfg [ 'UploadDir' ] = 'upload' ; |
Create a directory called ‘upload’ within the phpmyadmin directory.
1
|
C:\wamp\apps\phpmyadmin3.2.0.1\upload\ |
Then place the large sql file that you are trying to import into the new upload directory. Now when you go onto the db import page within phpmyadmin console you will notice a drop down present that wasn’t there before – it contains all of the sql files in the upload directory that you have just created. You can now select this and begin the import.
If the import file size is too large, we may encounter another issue when importing it, that is the timeout issue. Since the default timeout is 300s which is 5 minutes. For some large files, it's not enough, we need to change the \wamp\apps\phpmyadmin4.1.14\libraries\config.default.php.
Need to update the $cfg['ExecTimeLimit'] and change it to $cfg['ExecTimeLimit'] = 0; Here 0 means infinite time limit.
Please restart all services after changing config files.
If the above settings don't work and you still get below message :
Maximum execution time of 360 seconds exceeded in C:\wamp\apps\phpmyadmin4.1.14\libraries\plugins\import\ImportSql.class.php
You should go to \wamp\alias\phpmyadmin.conf and set the php_admin_value max_execution_time to 0.
Reference : Importing large files into mysql with phpmyadmin