How to Increase the phpMyAdmin Import File Size Limit (Apache, Nginx, Docker, cPanel)

Tested
What changed
Rewritten for current PHP versions, PHP-FPM, Docker and cPanel.
First written
2022
On this page: 8 sections

If phpMyAdmin rejects your SQL file with “You probably tried to upload a file that is too large. Please refer to documentation for a workaround for this limit.”, the limit is not set in phpMyAdmin. It comes from PHP, and sometimes from the web server in front of it. I ran into it when I moved my site to AWS: the database was 16MB and the import stopped at the 2MB default. Below is where the limit is set on each common setup, and how to raise it.

Quick answer

  • Raise upload_max_filesize and post_max_size in the php.ini your web server uses (not the command-line one), then restart Apache or PHP-FPM.
  • On Nginx, also raise client_max_body_size.
  • With the official phpMyAdmin Docker image, set UPLOAD_LIMIT.
  • On cPanel shared hosting you usually cannot raise it yourself. Compress the dump or import from the command line.
  • For very large databases, skip the browser upload and use the command line.

Check the current limit, and try compressing first

The Import tab shows the current maximum next to the file picker, for example (Max: 2,048KiB). PHP’s default upload_max_filesize is 2M, which is why so many servers stop at 2MB.

Before changing any settings, try compressing the dump. phpMyAdmin imports gzip, bzip2 and zip files directly, and the limit applies to the compressed file. SQL is plain text, so it usually shrinks a lot:

gzip -k database.sql    # creates database.sql.gz and keeps the originalCode language: Bash (bash)

Ubuntu or Debian with Apache

  1. Find your PHP version with ls /etc/php/. There is one folder per version, for example 8.3 on Ubuntu 24.04 or 8.1 on Ubuntu 22.04. Replace 8.3 below with yours.
  2. Open the php.ini that Apache uses: sudo nano /etc/php/8.3/apache2/php.ini
  3. Find these settings and change them (use your own sizes):
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300Code language: TOML, also INI (ini)

post_max_size must be at least as large as upload_max_filesize, because the file travels inside the POST request. Keep memory_limit above post_max_size. The two time limits matter for imports that take more than a minute or so.

4. Restart Apache:

sudo systemctl restart apache2Code language: Bash (bash)

Reload the Import tab: the Max value should now show the new size. If it does not, see “Still failing?” below.

Two tips. Instead of editing php.ini, you can put the same lines in a file of their own, such as /etc/php/8.3/apache2/conf.d/99-uploads.ini. Package upgrades never touch that file, and later you can see at a glance what you changed. And don’t trust php --ini here: it shows the command-line configuration (/etc/php/8.3/cli/php.ini), which the web server does not read.

Nginx with PHP-FPM

Here PHP runs as its own service, so there are two limits: PHP-FPM’s and Nginx’s.

  1. Set the same PHP values in /etc/php/8.3/fpm/php.ini, or in /etc/php/8.3/fpm/conf.d/99-uploads.ini.
  2. Raise Nginx’s request body limit. Its default is 1MB, and when an upload exceeds it Nginx answers 413 Request Entity Too Large before PHP sees the file. Add this to the server block for phpMyAdmin (or to the http block for all sites):
client_max_body_size 64M;Code language: Nginx (nginx)

3. Restart PHP-FPM and reload Nginx:

sudo systemctl restart php8.3-fpm
sudo nginx -t && sudo systemctl reload nginxCode language: Bash (bash)

Apache can run PHP through PHP-FPM too. If /etc/php/8.3/fpm exists and the Apache change above made no difference, edit the fpm php.ini and restart php8.3-fpm instead of Apache.

phpMyAdmin in Docker

The official phpmyadmin image sets both PHP values from one environment variable, UPLOAD_LIMIT, which defaults to 2048K. I checked it on phpMyAdmin 5.2.3 with PHP 8.3: with UPLOAD_LIMIT=64M, both upload_max_filesize and post_max_size read 64M.

docker run -d --name phpmyadmin -e PMA_HOST=db -e UPLOAD_LIMIT=64M -p 8080:80 phpmyadminCode language: Bash (bash)

Or in Docker Compose:

services:
  phpmyadmin:
    image: phpmyadmin
    environment:
      PMA_HOST: db
      UPLOAD_LIMIT: 64MCode language: YAML (yaml)

Recreate the container after changing it (docker compose up -d). MAX_EXECUTION_TIME and MEMORY_LIMIT work the same way for slow imports. If a reverse proxy such as Nginx sits in front of the container, its own body size limit applies as well.

Shared hosting with cPanel

The phpMyAdmin inside cPanel runs on cPanel’s own PHP, not your website’s, so the MultiPHP INI Editor does not change its limit. That limit is a server-wide setting in WHM (Tweak Settings, “cPanel PHP max upload size”), which only the host can change. On shared hosting, compress the dump first. If that is not enough, use the command-line import below through cPanel’s Terminal or SSH if your plan has it, or ask the host’s support to import the file for you.

For big databases, skip the browser upload

Once a dump reaches hundreds of megabytes, a browser upload tends to fail on time limits even after it clears the size limit. Two ways around that:

The command line. Upload the file to the server with scp or SFTP, then import it straight into MySQL or MariaDB. No PHP limits apply:

mysql -u dbuser -p dbname < database.sql

# compressed dump
gunzip < database.sql.gz | mysql -u dbuser -p dbnameCode language: Bash (bash)

phpMyAdmin’s upload directory. Set $cfg['UploadDir'] in config.inc.php to a folder the web server can read, and copy the dump into it. The Import tab then lets you choose the file from that folder. It never goes through a browser upload, so the upload limits don’t apply, but the time limits still do.

Still failing?

  • The Max value on the Import tab did not change. You edited a php.ini the web server does not read, or restarted the wrong service (apache2 versus php8.3-fpm).
  • 413 Request Entity Too Large. The web server or a proxy in front of it rejected the request: raise Nginx’s client_max_body_size. Cloudflare’s Free and Pro plans cap request bodies at 100MB, so bigger files have to go through the command line.
  • The import starts but stops partway. That is a time limit: PHP’s max_execution_time, or phpMyAdmin’s own $cfg['ExecTimeLimit'] (300 seconds by default). For a file that size, use the command line.

More re-tested in WordPress

Leave a comment

Your email address won’t be published. Name, email and comment are required.