Database Uploads for WordPress with PHP: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 4: | Line 4: | ||
Change some settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions. | Change some settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions. | ||
= | = PHP Settings for Large phpMyAdmin Imports = | ||
Large | |||
Large WordPress database imports through phpMyAdmin can fail when PHP upload limits, POST limits, memory limits, or execution timers are too low. | |||
== Main php.ini Settings == | |||
<syntaxhighlight lang="ini"> | <syntaxhighlight lang="ini"> | ||
| Line 19: | Line 18: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
; <code>upload_max_filesize</code> | |||
: Maximum size of an uploaded SQL file. | |||
; <code>post_max_size</code> | |||
: Maximum total HTTP POST request size. Set this larger than <code>upload_max_filesize</code>. | |||
; <code>memory_limit</code> | |||
: Maximum memory PHP may use. For large imports, set this larger than <code>post_max_size</code>. | |||
; <code>max_execution_time</code> | |||
: Maximum script execution time, in seconds. | |||
; <code>max_input_time</code> | |||
: Maximum time PHP may spend receiving input, including uploads. | |||
== phpMyAdmin Settings == | |||
These go in phpMyAdmin's <code>config.inc.php</code> file. | |||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
| Line 44: | Line 43: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<code>$cfg['UploadDir']</code> | ; <code>$cfg['ExecTimeLimit']</code> | ||
: phpMyAdmin execution time limit. | |||
; <code>$cfg['MemoryLimit']</code> | |||
: phpMyAdmin memory limit override. | |||
; <code>$cfg['UploadDir']</code> | |||
: Allows SQL files to be copied to a server-side upload directory and selected from phpMyAdmin, avoiding browser upload limits. | |||
== Per-Site Configuration == | == Per-Site Configuration == | ||
If PHP runs as an Apache module, settings may be placed in <code>.htaccess</code>: | |||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
php_value upload_max_filesize 512M | php_value upload_max_filesize 512M | ||
php_value post_max_size 600M | php_value post_max_size 600M | ||
| Line 59: | Line 64: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
If PHP runs through CGI, FastCGI, or PHP-FPM, use <code>.user.ini</code> instead: | |||
<syntaxhighlight lang="ini"> | <syntaxhighlight lang="ini"> | ||
| Line 71: | Line 76: | ||
== Notes == | == Notes == | ||
* | * Reload or restart the web server or PHP-FPM service after global PHP changes. | ||
* | * For very large databases, command-line import with <code>mysql</code> or <code>mariadb</code> is usually more reliable than browser upload through phpMyAdmin. | ||
* Web server limits may also apply, such as Apache request limits or Nginx <code>client_max_body_size</code>. | |||
== | == References == | ||
* [https://www.php.net/manual/en/ini.core.php PHP Manual: Core php.ini directives] | * [https://www.php.net/manual/en/ini.core.php PHP Manual: Core php.ini directives] | ||
* [https://www.php.net/manual/en/features.file-upload.common-pitfalls.php PHP Manual: File upload common pitfalls] | * [https://www.php.net/manual/en/features.file-upload.common-pitfalls.php PHP Manual: File upload common pitfalls] | ||
* [https://www.php.net/manual/en/configuration.changes.php PHP Manual: | * [https://www.php.net/manual/en/configuration.changes.php PHP Manual: Changing configuration settings] | ||
* [https://www.php.net/manual/en/configuration.file.per-user.php PHP Manual: .user.ini files] | * [https://www.php.net/manual/en/configuration.file.per-user.php PHP Manual: .user.ini files] | ||
* [https://docs.phpmyadmin.net/en/latest/config.html phpMyAdmin Documentation: Configuration] | * [https://docs.phpmyadmin.net/en/latest/config.html phpMyAdmin Documentation: Configuration] | ||
* [https://docs.phpmyadmin.net/en/ | * [https://docs.phpmyadmin.net/en/latest/faq.html#i-cannot-upload-big-dump-files-memory-http-or-timeout-problems phpMyAdmin FAQ: Cannot upload big dump files] | ||
Revision as of 22:57, 3 June 2026
...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 some settings in /etc/php.ini (or other locations like /opt/remi, if using REMI for multiple PHP versions.
PHP Settings for Large phpMyAdmin Imports
Large WordPress database imports through phpMyAdmin can fail when PHP upload limits, POST limits, memory limits, or execution timers are too low.
Main php.ini Settings
upload_max_filesize = 512M
post_max_size = 600M
memory_limit = 768M
max_execution_time = 600
max_input_time = 600upload_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.
phpMyAdmin Settings
These go in phpMyAdmin's config.inc.php file.
$cfg['ExecTimeLimit'] = 600;
$cfg['MemoryLimit'] = '768M';
$cfg['UploadDir'] = 'upload';$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.
Per-Site Configuration
If PHP runs as an Apache module, settings may be placed in .htaccess:
php_value upload_max_filesize 512M
php_value post_max_size 600M
php_value memory_limit 768M
php_value max_execution_time 600
php_value max_input_time 600If PHP runs through CGI, FastCGI, or PHP-FPM, use .user.ini instead:
upload_max_filesize = 512M
post_max_size = 600M
memory_limit = 768M
max_execution_time = 600
max_input_time = 600Notes
- Reload or restart the web server or PHP-FPM service after global PHP changes.
- For very large databases, command-line import with
mysqlormariadbis usually more reliable than browser upload through phpMyAdmin. - Web server limits may also apply, such as Apache request limits or Nginx
client_max_body_size.