1227 (42000)

MySQL Error 1227: Access Denied – You Need Super Privilege Fix

You're seeing this error when restoring a dump, creating a view, or changing definers. Happens a lot with MySQL 5.7 and 8.0 on shared hosting or when using partial privileges.

When This Error Shows Up

You're restoring a MySQL dump from one server to another, maybe from a production box to a local dev environment. Everything runs fine until you hit: ERROR 1227 (42000) at line X: Access denied; you need (at least one of) the SUPER privilege(s) for this operation. Or maybe you're trying to create a definer on a view or a trigger, and boom — same wall.

I've seen this most often when moving databases between different MySQL versions, especially from 5.7 to 8.0, or when using mysqldump with the --routines flag. Shared hosting accounts don't have SUPER privilege, so this error pops up like a bad dream.

Root Cause in Plain English

MySQL dump files include DEFINER statements. These tell the database who created a routine (like a stored procedure, function, trigger, or event). When you restore that dump, MySQL checks if the user running the restore has the SUPER privilege — because changing the definer requires that power.

If you don't have SUPER (common on cloud providers like AWS RDS, Google Cloud SQL, or shared hosting), MySQL says no. The tripwire is usually at a line like: DEFINER=`admin`@`%` or DEFINER=`root`@`localhost`.

The Fix – Step by Step

Three ways to beat this. Pick the one that fits your situation.

Option 1: Remove DEFINER Statements from the Dump (Best for Most)

This is the cleanest fix. Use sed or a text editor.

  1. Open the dump file in a text editor (like Notepad++, VS Code, or vim).
  2. Search for DEFINER — you'll see lines like /*!50013 DEFINER=`root`@`localhost`*/ or DEFINER=`admin`@`%`.
  3. Replace them with nothing. In vim: :%s/DEFINER[^ ]*//g
  4. Save the file, then try the restore again: mysql -u username -p database_name < dump.sql

On Linux or Mac, one-liner in terminal: sed 's/DEFINER[^ ]*//g' dump.sql > fixed_dump.sql.

Option 2: Grant SUPER Privilege (Only If You Have Root Access)

If you control the MySQL server, grant SUPER to your user. But this is rare — most hosts won't give it.

GRANT SUPER ON *.* TO 'your_user'@'localhost';
FLUSH PRIVILEGES;

Then try the restore again. If you still get errors, check the definer in the dump — you might need to skip to Option 1 anyway.

Option 3: Use mysqldump with --skip-definer (For New Dumps)

If you're creating the dump yourself, add the --skip-definer flag so the file never includes those lines to begin with.

mysqldump -u root -p --routines --events --triggers --skip-definer database_name > clean_dump.sql

Works with MySQL 8.0. For older versions like 5.7, you might need --skip-triggers --routines and handle them separately.

What to Check If It Still Fails

Sometimes the error sticks around. Here's what to look for:

  • Check the exact line number in the error message. Open the dump and go to that line. It might be a trigger or event, not a routine.
  • Look for DEFINER in views. MySQL views also have definers. Search for VIEW in the dump and check the definer.
  • If you're on AWS RDS, Google Cloud SQL, or similar: you absolutely cannot get SUPER. Use Option 1. Also, they might require you to set sql_mode via a parameter group — but that's a different fight.
  • Try restoring without routines first. Run: mysql -u user -p database_name < dump.sql --skip-routines and then import routines separately after editing their definers.
  • Last resort: Open the dump in a text editor, find all DEFINER lines, and replace them with a user that exists on your new server (like DEFINER=`your_existing_user`@`localhost`). This keeps the definers but uses your credentials.

I know this error is infuriating — it's one of those that makes you want to throw your laptop. But stick with Option 1, and 9 times out of 10 you're done in five minutes.

Related Errors in Database Errors
0X8004D00B XACT_E_NOISORETAIN (0x8004D00B) — MSDTC Isolation Fix 0XC019004E Fixing STATUS_TRANSACTION_NOT_FOUND (0XC019004E) in SQL Server MySQL Error 1236 (Got fatal error 1236 from master when reading data from binary MySQL Slave IO Thread Stopped Fix – 5 Real Steps 0X80040155 Fix REGDB_E_IIDNOTREG (0X80040155) Fast — Interface Not Registered

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.