// MySQL error reference

MySQL error 1227: Access denied; you need a privilege

The operation needs a global or dynamic privilege the account doesn't have, such as SUPER, SYSTEM_VARIABLES_ADMIN or PROCESS.

Error number
1227
Name
ER_SPECIFIC_ACCESS_DENIED_ERROR
SQLSTATE
42000
Category
Access and privileges
Error message
Access denied; you need (at least one of) the %s privilege(s) for this operation

What it means

Some statements need administrative privileges rather than table privileges: setting global variables, killing other users' threads, creating objects with a different DEFINER, and so on. The message lists the privileges that would allow it. It's common when importing a dump from another server into a managed database where you aren't a superuser.

Common causes

  • Importing a dump containing DEFINER= clauses for another user, or SET @@GLOBAL... statements.
  • SET GLOBAL or SET PERSIST without SYSTEM_VARIABLES_ADMIN (or SUPER).
  • Killing another user's query without CONNECTION_ADMIN (or SUPER).
  • Managed services that never grant SUPER.

How to fix it

  1. Read the privilege names in the message and grant one of them if you administer the server.

    GRANT SYSTEM_VARIABLES_ADMIN ON *.* TO 'admin'@'%';
  2. For dumps, strip or rewrite DEFINER clauses and global SET statements, or create the dump with options that leave them out, for example mysqldump --set-gtid-purged=OFF for GTID statements.

Related errors

More access and privileges errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.