Database Uploads for WordPress with PHP

wiki.TerraBase.info
Jump to navigation Jump to search

...wanna import a big database file for WordPress using phpMyAdmin? Good luck. The default settings PHP settings in php.ini will likely prevent that.

Solution?

Change settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions.

php.ini

Below are the main settings to modify. Jack 'em up higher if you have the RAM and / or need to import some really big stuff.

upload_max_filesize = 512M
post_max_size = 600M
memory_limit = 768M
max_execution_time = 600
max_input_time = 600

Directive Definitions

upload_max_filesize
Maximum size of an uploaded SQL file.
post_max_size
Maximum total HTTP POST request size. Set this larger than upload_max_filesize.
memory_limit
Maximum memory PHP may use. For large imports, set this larger than post_max_size.
max_execution_time
Maximum script execution time, in seconds.
max_input_time
Maximum time PHP may spend receiving input, including uploads.

Settings can also be done in phpMyAdmin

If it isn't desirable to modify system wide php.ini settings, just do it for phpMyAdmin. Location of where the config file is varies depending on the 'flavor' of Linux being used.

$cfg['ExecTimeLimit'] = 600;
$cfg['MemoryLimit'] = '768M';
$cfg['UploadDir'] = 'upload';

More Definitions

$cfg['ExecTimeLimit']
phpMyAdmin execution time limit.
$cfg['MemoryLimit']
phpMyAdmin memory limit override.
$cfg['UploadDir']
Allows SQL files to be copied to a server-side upload directory and selected from phpMyAdmin, avoiding browser upload limits.

.htaccess too

Settings can be done on a per website basis too.

upload_max_filesize = 512M
post_max_size = 600M
memory_limit = 768M
max_execution_time = 600
max_input_time = 600

Remember

  • Don't forget to restart PHP-FPM or other PHP related daemons / services if editing php.ini, as those settings won't apply until that's done
  • Restarting httpd or apache2, etc, won't cut it.

References