Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4
ERROR 1226 is about limits set on one account with CREATE USER ... WITH or ALTER USER ... WITH, not the server-wide connection limit (that is ERROR 1040). The message names the resource: max_user_connections, max_questions and so on.
The limits are stored in mysql.user. Below are two cases reproduced on MySQL 8.4.
01MAX_USER_CONNECTIONS: too many simultaneous connections for the account
app_user was created WITH MAX_USER_CONNECTIONS 1. Session A connected; session B, with the same correct password, was refused with has exceeded the 'max_user_connections' resource (current value: 1).
Setup
CREATE USER app_user IDENTIFIED BY 'App#2026' WITH MAX_USER_CONNECTIONS 1;Query OK, 0 rows affected (0.00 sec)$ mysql -h 127.0.0.1 -u app_user -p'App#2026'SELECT CURRENT_USER() AS who;+------------+
| who |
+------------+
| app_user@% |
+------------+
1 row in set (0.00 sec)$ mysql -h 127.0.0.1 -u app_user -p'App#2026'SELECT CURRENT_USER() AS who;ERROR 1226 (42000): User 'app_user' has exceeded the 'max_user_connections' resource (current value: 1)SELECT user, max_user_connections FROM mysql.user WHERE user = 'app_user';+----------+----------------------+
| user | max_user_connections |
+----------+----------------------+
| app_user | 1 |
+----------+----------------------+
1 row in set (0.00 sec)max_user_connections for app_user is 1: only one connection at a time.
ALTER USER app_user WITH MAX_USER_CONNECTIONS 10;Query OK, 0 rows affected (0.01 sec)ALTER USER app_user WITH MAX_USER_CONNECTIONS 10; and both sessions could connect.
$ mysql -h 127.0.0.1 -u app_user -p'App#2026'SELECT CURRENT_USER() AS who;+------------+
| who |
+------------+
| app_user@% |
+------------+
1 row in set (0.00 sec)$ mysql -h 127.0.0.1 -u app_user -p'App#2026'SELECT CURRENT_USER() AS who;+------------+
| who |
+------------+
| app_user@% |
+------------+
1 row in set (0.00 sec)02MAX_QUERIES_PER_HOUR: the hourly query limit was used up
app_user has MAX_QUERIES_PER_HOUR 3. In this run only the first two SELECTs returned rows; the third and fourth failed with has exceeded the 'max_questions' resource (current value: 3). So the limit can run out earlier than the number of statements you typed.
Setup
CREATE USER app_user IDENTIFIED BY 'App#2026' WITH MAX_QUERIES_PER_HOUR 3;Query OK, 0 rows affected (0.00 sec)$ mysql -h 127.0.0.1 -u app_user -p'App#2026'SELECT 1 AS q1;
SELECT 2 AS q2;
SELECT 3 AS q3;
SELECT 4 AS q4;+----+
| q1 |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
+----+
| q2 |
+----+
| 2 |
+----+
1 row in set (0.00 sec)
ERROR 1226 (42000): User 'app_user' has exceeded the 'max_questions' resource (current value: 3)
ERROR 1226 (42000): User 'app_user' has exceeded the 'max_questions' resource (current value: 3)SELECT user, max_questions FROM mysql.user WHERE user = 'app_user';+----------+---------------+
| user | max_questions |
+----------+---------------+
| app_user | 3 |
+----------+---------------+
1 row in set (0.00 sec)In mysql.user the hourly query limit is the max_questions column: 3.
ALTER USER app_user WITH MAX_QUERIES_PER_HOUR 0;Query OK, 0 rows affected (0.01 sec)ALTER USER app_user WITH MAX_QUERIES_PER_HOUR 0; removes the limit (0 = unlimited). All four SELECTs then ran.
$ mysql -h 127.0.0.1 -u app_user -p'App#2026'SELECT 1 AS q1;
SELECT 2 AS q2;
SELECT 3 AS q3;
SELECT 4 AS q4;+----+
| q1 |
+----+
| 1 |
+----+
1 row in set (0.00 sec)
+----+
| q2 |
+----+
| 2 |
+----+
1 row in set (0.00 sec)
+----+
| q3 |
+----+
| 3 |
+----+
1 row in set (0.00 sec)
+----+
| q4 |
+----+
| 4 |
+----+
1 row in set (0.00 sec)FAQ
What is the difference between ERROR 1226 and ERROR 1040?
ERROR 1040 means the whole server reached max_connections. ERROR 1226 means one account reached its own limit, such as MAX_USER_CONNECTIONS or MAX_QUERIES_PER_HOUR.
How do I check the resource limits of a MySQL user?
SELECT user, host, max_questions, max_updates, max_connections, max_user_connections FROM mysql.user WHERE user = '...'; 0 means no limit.
How do I remove the limit?
Set it to 0 with ALTER USER, e.g. ALTER USER app_user WITH MAX_QUERIES_PER_HOUR 0;, or raise it to a value you need.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13