DevOps
Increase File Upload Size in Ubuntu + Apache (For SQL & .gz Files)
Advantage AI Engineering · · 5 min read

Raise PHP upload limits so you can import large .sql and .sql.gz files through Apache—then verify with phpinfo and learn a faster terminal import pattern.
Running into the 2MB upload limit when uploading .sql or .sql.gz files on Ubuntu + Apache? This limit usually comes from PHP defaults. Here is a concise fix.
1. Edit php.ini
Check your installed PHP version:
php -vOpen the Apache SAPI php.ini for that version (replace 8.x with your major.minor, e.g. 8.2):
sudo nano /etc/php/8.x/apache2/php.iniUpdate (or add) these directives—values are a common starting point; tune to your workload:
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 512M
max_execution_time = 3002. Restart Apache
sudo systemctl restart apache23. Verify changes
Create a small phpinfo page in your web root (remove it after verification for security):
<?php phpinfo(); ?>Open it in the browser, for example:
http://your-server-ip/phpinfo.phpConfirm the updated values for:
- upload_max_filesize
- post_max_size
Bonus: import large SQL files faster
phpMyAdmin can be slow for very large dumps. When you have shell access, streaming a compressed backup straight into MySQL is often faster:
zcat backup.sql.gz | mysql -u root -p your_database