Most database errors that reach a website owner come from a handful of settings: “Too many connections”, “MySQL server has gone away”, “Got a packet bigger than ‘max_allowed_packet’ bytes”. Each one points to a server default — and MySQL and MariaDB don’t always share the same defaults, which is why an import that works on one fails on the other.
This page lists the defaults that matter, the error each one produces, and the differences between MySQL and MariaDB that break migrations. We didn’t copy these values from documentation: we read them directly from both servers.
mysqld --no-defaults --verbose --help — the values each server uses when no configuration file sets them. Distributions and hosting providers often change several of these; the last sections show how to check yours.Defaults at a glance
| Setting | MySQL 8.0 | MariaDB 10.11 | What it causes when too low |
|---|---|---|---|
max_connections | 151 | 151 | “Too many connections” |
max_user_connections | 0 (no per-user limit) | 0 | “User has exceeded the ‘max_user_connections’ resource” — shared hosts usually set one |
max_allowed_packet | 64 MB | 16 MB | “Got a packet bigger than ‘max_allowed_packet’ bytes”, or “MySQL server has gone away” during imports |
wait_timeout | 28,800 s (8 hours) | 28,800 s | “MySQL server has gone away” on idle connections |
connect_timeout | 10 s | 10 s | “Lost connection to MySQL server at ‘reading initial communication packet'” |
innodb_lock_wait_timeout | 50 s | 50 s | “Lock wait timeout exceeded; try restarting transaction” |
max_connect_errors | 100 | 100 | “Host is blocked because of many connection errors” |
innodb_buffer_pool_size | 128 MB | 128 MB | No error — just a slow database once the data outgrows it |
tmp_table_size / max_heap_table_size | 16 MB | 16 MB | Temporary tables spill to disk; “The table is full” for in-memory tables |
sort_buffer_size | 256 KB | 2 MB | Slower sorts on large result sets |
table_open_cache | 4,000 | 2,000 | Slower queries on sites with many tables |
| Query time limit | max_execution_time 0 (off) | max_statement_time 0 (off) | A runaway query can run until something else stops it |
long_query_time | 10 s | 10 s | Slow queries shorter than 10 s aren’t logged — and the slow log is off by default |
character_set_server | utf8mb4 | latin1 (compiled default) | Emoji and some characters break on latin1 tables |
| Default authentication | caching_sha2_password | mysql_native_password | “The server requested authentication method unknown to the client” with old clients |
The Ubuntu and Debian packages of MariaDB set utf8mb4 in their own configuration file, so the compiled latin1 default rarely reaches a fresh install there — but it can on a server built another way. And max_user_connections is the one hosting providers change most: on shared hosting, a per-user cap of a few dozen connections is common.
The errors, one by one
“Too many connections”
Every connection slot is in use. The default of 151 is plenty for most sites — when it runs out, the cause is usually connections piling up, not too many visitors: slow queries holding connections open, a traffic spike hitting uncached pages, or an application opening connections and not closing them.
Check how close you’ve come:
SHOW GLOBAL STATUS LIKE 'Max_used_connections';
SHOW GLOBAL STATUS LIKE 'Threads_connected';If Max_used_connections is close to max_connections, raise the limit — but also look at the slow query log, because a limit that keeps being reached is usually a symptom. On shared hosting, the message may mention max_user_connections instead: a per-account limit only the host can change.
“MySQL server has gone away”
Two different causes produce the same message:
- The connection sat idle longer than
wait_timeoutand the server closed it. Long-running scripts, cron jobs and workers that hold a connection between tasks hit this. The fix is to reconnect in the application, not to raise the timeout indefinitely. - A query or row was larger than
max_allowed_packet. Imports with large rows, big serialized options in WordPress or files stored in the database are the usual cases. Raise the limit on the server — and inmysqldumpor the client, which have their own setting.
“Got a packet bigger than ‘max_allowed_packet’ bytes”
The same limit, reported directly. It’s the classic error when importing a dump into MariaDB that was exported from MySQL: the defaults are 64 MB and 16 MB, so a row that fitted on one server doesn’t fit on the other.
[mysqld]
max_allowed_packet = 64M“Lock wait timeout exceeded; try restarting transaction”
A query waited more than 50 seconds for a row another transaction had locked. Raising innodb_lock_wait_timeout rarely helps: the real issue is a transaction that holds its locks too long — a slow update, or a process that opens a transaction and waits. Find it with SHOW ENGINE INNODB STATUS; or the list of running queries in SHOW PROCESSLIST;.
“Host is blocked because of many connection errors”
The server blocked an IP after 100 failed connection attempts in a row — usually an application with the wrong credentials, or a network problem interrupting handshakes. Fix the cause first, then unblock the host:
mysqladmin flush-hostsQueries that run forever
Neither server limits query time by default. MySQL’s max_execution_time applies to SELECT statements and is set in milliseconds; MariaDB’s max_statement_time applies to all statements and is set in seconds. The difference in units matters: max_execution_time = 30 in MySQL is 30 milliseconds, not 30 seconds. Without a limit, a runaway query runs until PHP, the web server or a timeout above it gives up — see our reference of default timeouts.
MySQL vs MariaDB: the differences that break migrations
MariaDB started as a copy of MySQL, and the two have drifted. Moving a site between them works most of the time — these are the differences that make it fail:
max_allowed_packet — 64 MB against 16 MB. Imports from MySQL into MariaDB fail on large rows. Raise the limit on the destination before importing.
sql_mode — MySQL 8 is stricter. Its default includes ONLY_FULL_GROUP_BY, NO_ZERO_DATE and NO_ZERO_IN_DATE; MariaDB’s doesn’t. Code that works on MariaDB can fail on MySQL 8 with two typical errors:
- “Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column” — a query written for the looser mode.
- “Invalid default value for ‘column'” — a table definition using
0000-00-00as a default date, common in older WordPress plugins.
The right fix is updating the code or the table; relaxing sql_mode on the server is the fallback.
Character set — utf8mb4 against latin1. Check the character set of your tables before moving; a latin1 table can’t store emoji and some accented characters correctly.
Authentication — caching_sha2_password in MySQL 8. Old clients and very old PHP versions can’t use it, and fail with “The server requested authentication method unknown to the client”. In MySQL 8.4, the older mysql_native_password method is no longer enabled by default at all. Current PHP versions handle caching_sha2_password without changes.
How to check your values
From any MySQL or MariaDB client — including phpMyAdmin’s SQL tab:
SHOW VARIABLES LIKE 'max_allowed_packet';
SELECT @@max_connections, @@wait_timeout, @@innodb_buffer_pool_size;In phpMyAdmin, the Variables tab on the server’s main page lists all of them. On shared hosting, you can read these values but usually can’t change them.
How to change them
In the configuration file, under the [mysqld] section — then restart the database:
| System | Configuration file |
|---|---|
| MySQL on Ubuntu / Debian | /etc/mysql/mysql.conf.d/mysqld.cnf |
| MariaDB on Ubuntu / Debian | /etc/mysql/mariadb.conf.d/50-server.cnf |
| AlmaLinux / Rocky / RHEL | /etc/my.cnf or a file in /etc/my.cnf.d/ |
| cPanel and DirectAdmin | /etc/my.cnf |
At runtime, with SET GLOBAL max_connections = 300; — the change applies immediately but is lost on restart. MySQL 8 adds SET PERSIST, which also writes it to disk; MariaDB doesn’t have it, so add the value to the configuration file too.
On innodb_buffer_pool_size: it’s the setting with the biggest effect on speed, and 128 MB is small for any real site. MySQL’s documentation suggests up to 80% of memory on a server dedicated to the database; on a VPS that also runs the web server and PHP, it has to be much less, or the database and PHP compete for the same RAM.
If the database won’t start after a change, the reason is in its error log — see our guide to log file locations.
Sources
- MySQL: Server System Variables — MySQL 8.0 Reference Manual
- MariaDB: Server System Variables — MariaDB Knowledge Base
- Values read from
mysqld8.0.46 andmariadbd10.11.14 with--no-defaults --verbose --help
A Copahost VPS gives you root access to MySQL or MariaDB — so you can size the buffer pool to your RAM, raise max_allowed_packet for a large import, and turn on the slow query log when something drags. SSD storage, full access and month-to-month billing.
See VPS plans →Frequently asked questions
What is the default max_connections in MySQL?
151, in both MySQL 8 and MariaDB. When it’s reached, new connections fail with “Too many connections”. Check Max_used_connections to see how close the server has come, and look for slow queries before raising the limit.
What is the default max_allowed_packet?
64 MB in MySQL 8 and 16 MB in MariaDB 10.11. The difference is why imports from MySQL into MariaDB can fail with “Got a packet bigger than ‘max_allowed_packet’ bytes”. Raise it under [mysqld] on the destination server.
What causes “MySQL server has gone away”?
Usually one of two things: a connection that sat idle longer than wait_timeout — 8 hours by default — and was closed, or a query larger than max_allowed_packet. Reconnecting in the application fixes the first; raising the packet limit fixes the second.
What is the default wait_timeout in MySQL?
28,800 seconds — 8 hours — in both MySQL and MariaDB. After that, the server closes an idle connection, and the next query on it fails with “MySQL server has gone away”.
What are the main differences between MySQL and MariaDB defaults?max_allowed_packet is 64 MB in MySQL and 16 MB in MariaDB; MySQL 8’s sql_mode is stricter, with ONLY_FULL_GROUP_BY and NO_ZERO_DATE; MySQL defaults to the utf8mb4 character set, while MariaDB 10.11’s compiled default is latin1; and MySQL 8 uses caching_sha2_password for authentication.
How do I check my MySQL settings?
Run SHOW VARIABLES LIKE 'setting_name'; or SELECT @@setting_name; from any client, including phpMyAdmin’s SQL tab. phpMyAdmin also lists every value in the Variables tab on the server’s main page.
Conclusion
Most database errors on a website trace back to a short list of defaults: 151 connections, an 8-hour idle timeout, a packet limit, a 50-second lock wait — and a buffer pool of 128 MB that’s small for any real site. Each error names its setting, if you know which one to look for.
The part that catches people is moving between MySQL and MariaDB. They share most defaults but not all: a smaller packet limit in MariaDB, a stricter sql_mode in MySQL 8, a different character set and a newer authentication method. Check those four before a migration, and most “it worked on the old server” problems never happen.
