When phpMyAdmin export is failing, it is often due to MySQL configuration issues, such as:
- Insufficient memory or packet size.
- Timeout limits causing the process to abort.
- Corrupt tables preventing data extraction.
- Incorrect privileges stopping phpMyAdmin from exporting data.
This guide walks through MySQL-specific configurations to fix export problems from a server administrator's perspective.
Identify the MySQL Issue
Before modifying configurations, determine why MySQL export is failing.
Check MySQL Error Logs
sudo tail -f /var/log/mysql/error.log
Common errors include:
MySQL server has gone away
Packet size too large
Lock wait timeout exceeded
Check MySQL Process List
mysql -u root -p -e "SHOW PROCESSLIST;"
- If queries are stuck, it may be a timeout issue.
- If queries are aborted, it may be packet size or memory-related.
Check phpMyAdmin Error Logs
tail -f /var/log/syslog | grep phpmyadmin
If errors appear, proceed with fixing MySQL configurations.
Increase MySQL Configuration Limits
Edit the MySQL configuration file:
sudo nano /etc/mysql/my.cnf
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Add or modify the following sections:
Increase max_allowed_packet
If exporting large tables, increase the packet size:
[mysqld]
max_allowed_packet = 512M
Why? MySQL drops connections when the packet size is too small.
Increase Query Timeout Limits
If phpMyAdmin stops during export, increase:
[mysqld]
net_read_timeout = 600
net_write_timeout = 600
wait_timeout = 600
interactive_timeout = 600
Why? These values prevent long-running queries from timing out.
Increase innodb_buffer_pool_size for Large Databases
If the database is large, increase InnoDB memory:
[mysqld]
innodb_buffer_pool_size = 1G
innodb_log_file_size = 512M
innodb_log_buffer_size = 128M
innodb_flush_log_at_trx_commit = 2
Why? This improves read/write speeds and prevents slow exports.
Optimize tmp_table_size and max_heap_table_size
To prevent MySQL from using disk-based temp tables, increase:
[mysqld]
tmp_table_size = 512M
max_heap_table_size = 512M
Why? Ensures temporary tables fit in RAM, speeding up the export process.
Restart MySQL Service
After making changes, restart MySQL:
sudo systemctl restart mysql
Check if MySQL is running correctly:
sudo systemctl status mysql
Verify Configuration Changes
Run:
mysql -u root -p -e "SHOW VARIABLES LIKE 'max_allowed_packet';"
mysql -u root -p -e "SHOW VARIABLES LIKE 'wait_timeout';"
mysql -u root -p -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_size';"
Ensure they match your updated settings.
Check and Repair Database Tables
If MySQL configuration changes do not fix the issue, check for corrupt tables.
Run a Full Check
mysqlcheck -u root -p --all-databases
Repair Corrupt Tables
mysqlcheck -u root -p --repair --all-databases
If a specific database is failing:
mysqlcheck -u root -p --repair database_name
Optimize Database for Faster Exports
If the export is still slow or failing, optimize the tables.
Defragment Tables
mysqlcheck -u root -p --optimize --all-databases
Manually Optimize Large Tables
If a single table is large, optimize it:
OPTIMIZE TABLE database_name.table_name;
Use mysqldump as an Alternative
If phpMyAdmin export still fails, use the command line:
mysqldump -u root -p database_name > /backup/database.sql
For large exports:
mysqldump -u root -p --max_allowed_packet=512M --single-transaction database_name > /backup/database.sql
If compression is needed:
mysqldump -u root -p database_name | gzip > /backup/database.sql.gz
Summary
| Issue |
Fix |
| Export fails due to packet size |
Increase max_allowed_packet = 512M |
| Export times out |
Increase wait_timeout = 600 |
| Large database export fails |
Increase innodb_buffer_pool_size = 1G |
| MySQL crashes during export |
Optimize database tables (OPTIMIZE TABLE) |
| Export still failing? |
Use mysqldump |
By following this systematic MySQL configuration approach, a server administrator can fix phpMyAdmin export issues, ensure fast and stable database exports, and prevent timeouts or packet loss.