Get your free beta license ↗
Databases · MariaDB

An import fails with “Server has gone away”

Last updated 30 Nov 2026
Summary

An import loses its connection when a row exceeds MariaDB's default max_allowed_packet limit of 16 MB. The log reports the oversized packet, and raising the limit on both the server and the client fixes the import.

Symptoms

The import stops with this error.

Output
ERROR 2006 (HY000) at line 2: Server has gone away

At the same time, MariaDB logs the following warning. Check /var/log/mariadb/mariadb.log on AlmaLinux or run journalctl -u mariadb on Ubuntu.

Output
[Warning] Aborted connection 38 to db: 'example_db' user: 'example_db' host: 'localhost' (Got a packet bigger than 'max_allowed_packet' bytes)

Cause

A row in the dump, often one with a large blob or a long text value, exceeds max_allowed_packet. The server defaults to 16 MB, or 16777216 bytes. UrbeStack leaves the value to the distribution and to you.

The server and the mariadb client each have their own limit. Both must accept the packet.

Resolution

  1. Check the server's current limit.

    mariadb -N -e "SELECT @@global.max_allowed_packet"
  2. Raise the server's limit to 64 MB immediately. This setting lasts until MariaDB restarts.

    mariadb -e "SET GLOBAL max_allowed_packet=67108864"
  3. To keep the setting after a restart, add max_allowed_packet = 64M under [mysqld] in /etc/my.cnf.d/mariadb-server.cnf on AlmaLinux or /etc/mysql/mariadb.conf.d/50-server.cnf on Ubuntu. Then restart MariaDB.

    urbestack-service-restart --name mariadb
  4. Import the dump with the client's limit set to 64 MB as well.

    mariadb --max-allowed-packet=64M -u example_db -p example_db < dump.sql