When This Happens
You're in phpMyAdmin (say version 5.2.1 on a shared host or local XAMPP). You export a table with 10,000 rows to CSV. You open the file in Excel or Notepad and only see 5,000 rows. The rest are gone. No error message, no warning. Just missing data.
I saw this last month with a client's inventory table. 12,000 products exported to CSV, only 6,800 showed up. They thought the database was corrupted. It wasn't. The fix took 30 seconds.
Root Cause
It's not a bug in phpMyAdmin’s export logic. It's a PHP memory limit. When you export a large dataset, phpMyAdmin has to hold all those rows in memory before writing them to the CSV file. If PHP's memory limit is too low (common default: 128MB or 256MB), PHP stops processing mid-export. It doesn't throw an error — it just silently stops fetching rows.
Think of it like a bucket that can only hold 5 gallons. If you try to pour 10 gallons in, the bucket overflows and you lose half the water. The export script doesn't tell you it overflowed. It just gives you what fit.
The Fix
You have two ways to fix this. The first is quick and works for most people. The second is more permanent.
Option 1: Change Memory Limit in phpMyAdmin Config
- Open the file
/path/to/phpmyadmin/libraries/config.default.php. On XAMPP, it's usually inC:\xampp\phpMyAdmin\libraries\config.default.php. - Search for this line:
If it's set to$cfg['MemoryLimit'] = '-1';-1, that means no limit. But on many setups, it's set to'256M'or'128M'. Change it to-1or a higher value like'512M'. I recommend'512M'unless your server has less than 1GB RAM. - Save the file.
- Restart your web server (Apache, Nginx, etc.). On XAMPP, stop and start Apache from the control panel.
Option 2: Override in config.inc.php (if option 1 doesn't work)
- Open
/path/to/phpmyadmin/config.inc.php. If it doesn't exist, copyconfig.sample.inc.phptoconfig.inc.php. - Add this line near the top:
$cfg['MemoryLimit'] = '512M'; - Save and restart Apache.
What to Check If It Still Fails
If the rows are still missing after this, check these three things:
- PHP.ini memory limit — open
php.iniand look formemory_limit. Set it to at least512M. On shared hosts, you might need to ask support or use a.user.inifile. - Max execution time — export can be slow for big tables. Set
max_execution_timeto0(no limit) inphp.inior add$cfg['ExecTimeLimit'] = 0;toconfig.inc.php. - Use a different export method — instead of the web interface, use the MySQL command line:
This bypasses PHP entirely and never hits memory limits.mysql -u username -p database_name -e "SELECT * FROM table_name" > output.csv
Also, check if you're using an old phpMyAdmin version. Versions before 5.0 had a known bug where export would silently truncate rows if the CSV included special characters. Upgrade to 5.2.2 or later. But in my experience, 9 times out of 10, it's the memory limit.
Quick tip: If you're on a shared host that won't let you change PHP memory, ask them to set it higher or export via MySQL command line. Most hosts will do it in 5 minutes.