phpMyAdmin will not import a big SQL file
Import fails with a file size or upload error in phpMyAdminShort 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.
Fix it fast
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.sql2Match what you see, then jump to its fix
- 1
The 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
The upload finishes, but the import stops part way and only some tables exist.The import hits max_execution_time or memory_limit halfwayFix - 3
Shared hosting, or a managed server where PHP settings are fixed.You cannot edit php.ini on this hostFix - 4
You can log in to the server over SSH.You have shell access: skip the browserFix
- 1
What does the error look like?
Import fails with a file size or upload error in phpMyAdminImport runs for a while, then the page stops or shows a blank resultThe 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.ini2Fix
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 = 256M3Verify
Reload phpMyAdmin and read the new maximum under the file field on the Import tab.
ls -lh dump.sqlConfirmed by php.net
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.ini2Fix
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 = 512M3Verify
Repeat the import and confirm the last table in the dump exists.
SHOW TABLES;Confirmed by docs.phpmyadmin.net
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.php2Fix
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/uploadConfirmed by docs.phpmyadmin.net
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 -p2Fix
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
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
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 fixDatabases
Laravel query fails: conversion from one collation into another is impossible
SQLSTATE[HY000]: General error: 3988 Conversion from collation utf8_unicode_ci into utf8mb4_0900_ai_ci impossible for parameter
MySQL is comparing or binding a value whose character set cannot be converted into the one on the other side.
3 causes, each with a fixDatabases
PHP cannot connect to MySQL: the connection attempt failed
Error 2003
Error 2003 means the TCP connection to MySQL never opened.
4 causes, each with a fixDatabases
The client cannot reach the MySQL or MariaDB server through its Unix socket file
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2) (MariaDB client wording)
Error 2002 means the client tried the Unix socket file named in the message and found nothing it could talk to.
4 causes, each with a fixDatabases
MySQL or MariaDB: Column count of mysql.proc is wrong, table probably corrupted
Error 1558: Column count of mysql.proc is wrong
The mysql.proc system table has a different number of columns than the running server expects.
3 causes, each with a fixDatabases
Saving an empty date from PHP into a MySQL DATETIME column fails
The column holds 0000-00-00 00:00:00 instead of NULL
An empty string is not NULL.
4 causes, each with a fix