MySQL & MariaDB error 1227: Access denied; you need (at least one of) the SUPER privilege(s)
Access denied; you need (at least one of) the SUPER or SET_ANY_DEFINER privilege(s) for this operation (8.4.13) The statement needs an administrative privilege the account doesn't have, for example to change a global variable, set another user as DEFINER, or read/write files. MySQL 8.0 split SUPER into finer dynamic privileges.
| MySQL | MariaDB | |
|---|---|---|
| Symbol | ER_SPECIFIC_ACCESS_DENIED_ERROR | ER_SPECIFIC_ACCESS_DENIED_ERROR |
| SQLSTATE | 42000 | 42000 |
| Type | Server error | Server error |
| Versions | every release since 5.0 active | every release since 5.5 active |
What it means
Access denied; you need (at least one of) the SUPER or SYSTEM_VARIABLES_ADMIN privilege(s) for this operation. The message lists the privileges that would allow it. MySQL 8.0 replaced most uses of SUPER with dynamic privileges (SYSTEM_VARIABLES_ADMIN, SET_USER_ID / SET_ANY_DEFINER, BINLOG_ADMIN, CONNECTION_ADMIN …). MariaDB has its own split (10.5+: READ_ONLY ADMIN, BINLOG ADMIN, SET USER …).
Why it happens
SET GLOBAL …by an ordinary user.- Restoring a dump on managed hosting (Amazon RDS, Aurora, Azure, Cloud SQL): the dump contains
DEFINER=clauses naming another user, orSET @@GLOBAL.GTID_PURGED/SET @@SESSION.SQL_LOG_BIN. The cloud admin account isn’t a real SUPER user. SELECT … INTO OUTFILE/LOAD DATA INFILEwithout the FILE privilege: 1227 on MySQL 8.0+ and MariaDB (5.x reported it as the misleading 1045).KILLof another user’s connection,CHANGE MASTER/CHANGE REPLICATION SOURCE,PURGE BINARY LOGS.
How to fix it
- Use the session form where it exists:
SET SESSION sql_mode = …instead ofSET GLOBAL. - For dumps: create them with
mysqldump --set-gtid-purged=OFF --skip-definer(MySQL Shellutil.dumpInstancehascompatibility: ["strip_definers"]), or removeDEFINER=withsedbefore importing. - Grant the specific privilege the message names, for example
GRANT SYSTEM_VARIABLES_ADMIN ON *.* TO …(MySQL 8.0), rather than SUPER.
Reproduce it yourself
These steps are the exact test our harness runs. Use a scratch server, never production.
Connect with
mysql -u root -pand create a scratch database:CREATE DATABASE demo; USE demo;Run:
CREATE USER 'appuser'@'%' IDENTIFIED BY 'Test#1234';In a shell on the database host:
mysql -uappuser -p'Test#1234' -h127.0.0.1 -e 'SET GLOBAL max_connections = 200'
You get: ERROR 1227 (42000) at line 1: Access denied; you need (at least one of) the CONNECTION ADMIN privilege(s) for this operation(11.8.9)
Verified fixes
Change it for your session only, or have an admin grant the dynamic privilege
CREATE USER 'appuser'@'%' IDENTIFIED BY 'Test#1234';mysql -uappuser -p'Test#1234' -h127.0.0.1 -N -e 'SET SESSION sql_mode = "STRICT_ALL_TABLES"; SELECT @@SESSION.sql_mode'
Tested on
| Step | MySQL | MariaDB | |||||||
|---|---|---|---|---|---|---|---|---|---|
| 5.6 | 5.7 | 8.0 | 8.4 | 9 | 10.6 | 10.11 | 11.4 | 11.8 | |
| An ordinary user changes a global setting repro | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 |
| An ordinary user creates a view with someone else as DEFINER version check | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 | ✓ 1227 |
| Change it for your session only, or have an admin grant the dynamic privilege fix | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Related errors
Where this error shows up in our guides
- OUTFILE required permissions · INTO OUTFILE as a user without FILE privilege (1045 on 5.x, clearer 1227 on 8.0+/MariaDB) MySQL 8.0 8.4 9MariaDB 10.6 10.11 11.4 11.8
How the message changed between versions
| MySQL from | Symbol | Message |
|---|---|---|
| 5.0.96 | ER_SPECIFIC_ACCESS_DENIED_ERROR | Access denied; you need the %-.128s privilege for this operation |
| 5.5.63 | ER_SPECIFIC_ACCESS_DENIED_ERROR | Access denied; you need (at least one of) the %-.128s privilege(s) for this operation |