Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

phpMyAdmin will not import a big SQL file

ErrorImport fails with a file size or upload error in phpMyAdmin

Short answer

phpMyAdmin hands the upload to PHP, so PHP's limits decide the maximum size. Raise upload_max_filesize, keep post_max_size larger than it, and keep memory_limit larger than both. If you cannot edit php.ini, copy the dump to the server and import it from the UploadDir folder, or run it from the mysql client.

  • Applies to phpMyAdmin 5.2, PHP 8.3, PHP 8.4, MySQL 8.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at the maximum size phpMyAdmin prints under the file field on the Import tab. It is the smaller of the two PHP upload limits. Then compare it with the size of your dump.

    ls -lh dump.sql
  2. 2Match what you see, then jump to its fix

    1. 1The limit shown on the Import tab is smaller than your file, or the upload does nothing at all. When POST data exceeds post_max_size, PHP leaves $_POST and $_FILES empty.upload_max_filesize or post_max_size is smaller than the dumpFix
    2. 2The upload finishes, but the import stops part way and only some tables exist.The import hits max_execution_time or memory_limit halfwayFix
    3. 3Shared hosting, or a managed server where PHP settings are fixed.You cannot edit php.ini on this hostFix
    4. 4You can log in to the server over SSH.You have shell access: skip the browserFix

What does the error look like?

  • Import fails with a file size or upload error in phpMyAdmin
  • Import runs for a while, then the page stops or shows a blank result
  • The import file field accepts only a small maximum size (the number shown under it)

Cause 1 of 4

upload_max_filesize or post_max_size is smaller than the dump

1Check

PHP ships with 2M for upload_max_filesize and 8M for post_max_size. Open the php.ini that your web server uses and read both values.

grep -E "^(upload_max_filesize|post_max_size|memory_limit)" /etc/php/8.3/apache2/php.ini

2Fix

Set upload_max_filesize above the dump size, post_max_size above that, and memory_limit above post_max_size. Then restart the web server or PHP-FPM so the new php.ini is read. These two settings cannot be changed at runtime with ini_set, so they must go in php.ini.

; php.ini
upload_max_filesize = 128M
post_max_size = 136M
memory_limit = 256M

3Verify

Reload phpMyAdmin and read the new maximum under the file field on the Import tab.

ls -lh dump.sql

Confirmed by php.net

Did this fix it?

Cause 2 of 4

The import hits max_execution_time or memory_limit halfway

1Check

The phpMyAdmin FAQ lists max_execution_time, upload_max_filesize, memory_limit and post_max_size together as the limits that stop a big dump. The limit that matters here is the time one request may run.

grep -E "^(max_execution_time|memory_limit)" /etc/php/8.3/apache2/php.ini

2Fix

Raise max_execution_time and memory_limit in the same php.ini, or skip the browser entirely with the next two causes. Newer phpMyAdmin releases rewrote the import engine to cope with big files, so also run the current release.

; php.ini
max_execution_time = 600
memory_limit = 512M

3Verify

Repeat the import and confirm the last table in the dump exists.

SHOW TABLES;

Confirmed by docs.phpmyadmin.net

Did this fix it?

Cause 3 of 4

You cannot edit php.ini on this host

1Check

If the host will not change the PHP limits, the upload through the browser is the part that cannot be fixed. phpMyAdmin can read a file that is already on the server.

grep -n "UploadDir" /path/to/phpmyadmin/config.inc.php

2Fix

Copy the dump to the server by scp or FTP, set the UploadDir directive in config.inc.php to that folder, and pick the file from the list on the Import tab. The FAQ describes this as the way to upload a file by scp, FTP or any file transfer method.

// config.inc.php
$cfg['UploadDir'] = '/var/lib/phpmyadmin/upload';

3Verify

Open the Import tab again. The Import tab now offers the files from that folder.

ls -l /var/lib/phpmyadmin/upload

Confirmed by docs.phpmyadmin.net

Did this fix it?

Cause 4 of 4

You have shell access: skip the browser

1Check

The FAQ names the mysql client's source command as the way to load a large dump when you have shell access.

mysql -u root -p

2Fix

Choose the database, then run the dump with source from inside the client.

USE mydb;
source /path/to/dump.sql;

3Verify

List the tables and compare the count with the dump.

SHOW TABLES;

Confirmed by docs.phpmyadmin.net

Did this fix it?

How do I stop it coming back?

  • Keep upload_max_filesize, post_max_size and memory_limit in that increasing order whenever you change one of them.
  • Run a current phpMyAdmin release, because the import engine was rewritten for large files.
  • For backups of any size, restore with the mysql client instead of the browser.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Databases

Laravel bulk insert fails with 'too many placeholders'

SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders

Laravel sends one placeholder per value, so one insert of many rows times many columns, or a whereIn with a huge list, creates a statement MySQL refuses.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.