×


PHPMyAdmin import database timeout - Fix it Now ?

Timeout error during import database indicates that the file you are trying to upload exceeds the limit set from the configuration files.

Just recently, one of our customers came across the PHPMyAdmin import database timeout error while importing SQL files into PHPMyAdmin.

It takes a long time and displays the timeout error.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related PHP queries.


Nature of PHPMyAdmin import database timeout

This error can occur if the database size is too large or the network connection is too slow.

PHPMyAdmin does not rely on the timeout or memory limit set in cPanel. It takes its values from the server default timeout specified in WHM.


How to fix PHPMyAdmin import database timeout ?

1. If we have shell access, we log in to the user account as the cPanel user and run:

# mysql -u username -p

In the prompt we enter the password then run the command:

$ mysql> use database_name;

Then we import the database:

source /our/path/to/backup.sql;

OR

mysql database_name < /our/path/to/backup.sql;

We recommend the following tip if the database size is large.

If in case there is no shell access, we have to contact the hosting provider with the backup file.


2. If the import is to be done via cPanel provided PHPMyAdmin itself, then we need to increase the timeout.

To do so, go to, WHM >> Tweak Settings >> cPanel PHP max execution time.


3. Another option is to import the backup as chunks but it is more complex.


4. To increase the phpMyAdmin Session Timeout, open config.inc.php in the root phpMyAdmin directory and add:

$cfg[‘LoginCookieValidity’] = <your_new_timeout>;

Here, the your_new_timeout is a number larger than 1800.


5. If we use WAMP, then there is a file in <our-wamp-dir>\alias\phpmyadmin.conf which overrides a few php.ini options.

We edit:

# To import big file we can increase values
php_admin_value upload_max_filesize 512M
php_admin_value post_max_size 512M
php_admin_value max_execution_time 600
php_admin_value max_input_time 600

6. In cPanel/WHM, the location of file config.default.php is under /usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries.


But if we use Plesk, change the settings in /usr/local/psa/admin/htdocs/domains/databases/phpMyAdmin/libraries/config.default.php.

We change $cfg[‘ExecTimeLimit’] = 300; to $cfg[‘ExecTimeLimit’] = 0;

Then we restart apache and mysql services.

We can restart with Plesk UI or use:

/etc/init.d/psa restart and /etc/init.d/httpd restart


7. Starting from Plesk 12.5, we can import databases via Plesk.

To do so, browse to Home > Domains > example.com > Databases and use importing functionality.


[Couldn't fix this PHPMyadmin error? We are here for you. ]


Conclusion

This article covers methods to fix PHPMyAdmin import database timeout error. This error happens because of a huge file and the restoration process fails with timeout.


To resolve this error, 

1. Login to the server over SSH.

2. Create the file config.inc.php.

For Plesk Onyx and Plesk Obsidian below 18.0.30:

# cp -p /usr/local/psa/admin/htdocs/domains/databases/phpMyAdmin/libraries/config.default.php /usr/local/psa/admin/htdocs/domains/databases/phpMyAdmin/config.inc.php

For Plesk Obsidian 18.0.30 and above:

# cp -p /usr/local/psa/phpMyAdmin/libraries/config.default.php /usr/local/psa/phpMyAdmin/config.inc.php

3. Increase the value of $cfg['ExecTimeLimit'] in config.inc.php created on step 2:

$cfg['ExecTimeLimit'] = 3600;

4. Increase the settings in /etc/sw-cp-server/config to avoid '504 Gateway Timeout' error:

fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;

5. Restart sw-cp-server:

$ service sw-cp-server restart