ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled appears when an account without SUPER runs CREATE FUNCTION or CREATE TRIGGER on a server that writes a binary log. Nothing is broken. MySQL is refusing to let an untrusted account create code that runs inside replicated statements. The error text already names the switch, log_bin_trust_function_creators, and calls it "less safe". The question is whether it is less safe for your server.
mysql> CREATE FUNCTION order_total(p_id INT) RETURNS DECIMAL(10,2)
-> DETERMINISTIC READS SQL DATA
-> RETURN (SELECT SUM(amount) FROM order_items WHERE order_id = p_id);
ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled
(you *might* want to use the less safe log_bin_trust_function_creators variable)
When exactly it fires
In the error reference 1419 is ER_BINLOG_CREATE_ROUTINE_NEED_SUPER. The MySQL 8.4 source raises it in two places: when a stored function is created (sp.cc) and when a trigger is created (sql_trigger.cc). In both places all three conditions must be true:
- the binary log is open. It is enabled by default and switched off only with
--skip-log-binor--disable-log-bin(stored program logging); log_bin_trust_function_creatorsis 0, which is the default (binary log options);- the account does not have the SUPER privilege.
Stored procedures and events are not affected, which is why CREATE PROCEDURE works for the same user. Declaring a function DETERMINISTIC does not help either. In the source, the SUPER check runs even for deterministic functions.
A related error comes from the same check: ERROR 1418, "This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration". With the default setting, a function must declare one of these characteristics. ALTER FUNCTION does not check SUPER in the 8.4 source, but it can raise 1418 when you change the characteristics of a function that is not deterministic. Note that MySQL does not verify that a function declared DETERMINISTIC really is deterministic. It trusts the creator.
The 8.4 manual and the server do not agree. The 8.4 manual says creating a function needs the SET_ANY_DEFINER privilege, which MySQL 8.2.0 introduced to replace SET_USER_ID. The 8.4 server source still checks SUPER_ACL, and the message still says SUPER. Granting SET_ANY_DEFINER alone is not enough to avoid 1419.
Step 1: check the server and your account
SELECT @@log_bin,
@@log_bin_trust_function_creators,
@@binlog_format;
SHOW GRANTS FOR CURRENT_USER();
The value that matters most is binlog_format. The default is ROW.
Why the rule exists
The documentation explains that the danger is statement-based logging. When a statement that calls a function is written to the binary log as SQL text, replicas and point-in-time restores run the function again. A non-deterministic function, for example one that uses UUID(), then produces different data on the replica. The replica's applier thread also runs with full privileges unless replication privilege checks are set up, so a routine could contain a statement that does something dangerous only on the replica.
With row-based logging, the binary log contains the row changes made by the function or trigger, not the call itself. That is why MySQL 8.0.34 deprecated log_bin_trust_function_creators together with binlog_format: both only matter for statement-based logging, which MySQL plans to stop supporting.
Fixes, from best to worst
- On ROW format, trust function creators. If
binlog_formatisROWon this server and on every server that may become a source, the main risk of statement replay does not apply. Turn the check off, and persist it so it survives a restart:
Keep in mind what the switch also does. Any account with-- only after you have confirmed binlog_format = ROW SET PERSIST log_bin_trust_function_creators = 1; -- survives a restart -- MySQL 8.0.34+ and 8.4 answer with a deprecation warning; the setting still worksCREATE ROUTINEorTRIGGERcan now create functions and triggers. Grant those privileges only to accounts that deploy code. - Deploy routines with a dedicated admin account. If you cannot change the variable, run the migrations that create functions and triggers as an account that has SUPER. SUPER is deprecated and very broad, so keep that account out of applications and use it only in the deployment pipeline.
- On Amazon RDS and Aurora, use the parameter group. AWS does not give the master user SUPER. AWS says to set
log_bin_trust_function_creatorsto 1 in a custom DB parameter group attached to the instance. The default parameter group cannot be changed, and in our experienceSET GLOBALfor this variable is refused on RDS. Other managed services have similar settings, so check your provider's documentation. - Do not turn off the binary log to make the error go away. Starting the server with
--skip-log-binstops replication and point-in-time recovery. Running the migration withSET sql_log_bin = 0creates the function only on this server. The replicas never get it, and the first query that calls it there fails.
What changes on large databases and fleets
On one test server, 1419 is a five-minute fix. With many servers, replicas and automated deploys, the same setting needs a policy:
- Dev and prod often differ. In our experience the migration passes on a developer laptop or in CI because the test container runs with the binary log off, and fails in production. Run CI with the same binary log settings as production.
- Every server that can become a source needs the same value. In our experience a failover onto a replica with the default value is the classic way 1419 appears months after it was "fixed": the next deploy creates a trigger on the new source and fails. Manage the setting with configuration management or
SET PERSISTon all members, not by hand on one server. - Check the format before you trust creators. Relaxing the check on a server that still uses
STATEMENTorMIXEDbrings back exactly the divergence the rule prevents. If you still run statement-based logging, plan the move to ROW before your upgrade to MySQL 8.4, because both variables are deprecated and may be removed. - Row-based logging means bigger binary logs. A trigger that updates many rows writes every changed row to the binary log. Watch binary log volume and retention after you add heavy triggers, as described in our article on purging binary logs safely.
- Dumps carry definers. Routines and triggers in a dump include a
DEFINERclause. Restoring them under another account fails without the privilege to set any definer:SET_ANY_DEFINERsince MySQL 8.2 (privileges). Restore schema objects with the deploy account, or remove definer clauses as part of the migration. - Audit what is already there. Functions created while the check was off may declare
DETERMINISTICwhen they are not. Review them before you depend on statement-based replicas or restores:
SELECT routine_schema, routine_name, is_deterministic, sql_data_access, definer
FROM information_schema.routines
WHERE routine_type = 'FUNCTION'
AND routine_schema NOT IN ('mysql', 'sys', 'information_schema', 'performance_schema')
ORDER BY routine_schema, routine_name;
Key takeaways
- 1419 fires on CREATE FUNCTION and CREATE TRIGGER when the binary log is on,
log_bin_trust_function_creatorsis 0 and the account lacks SUPER. Procedures and events are not affected. - The risk is statement-based logging. With
binlog_format = ROWon every possible source, setting the variable to 1 is the usual fix. - On RDS and Aurora, set it in a custom parameter group.
- Never disable the binary log or use
sql_log_bin = 0to deploy routines. - Keep the setting identical on all servers that can become a source, and run CI with production's binary log settings.