MySQL raises error 1125 (ER_UDF_EXISTS) when a CREATE FUNCTION statement attempts to define a user-defined function with a name already registered in the same database.
MySQL Error 1125 ER_UDF_EXISTS appears when you run CREATE FUNCTION for a name that already exists in the current schema. Drop or rename the existing routine, or run the new function in a different database to solve the problem quickly.
Function '%s' already exists
MySQL throws error 1125 (SQLSTATE HY000) with the message Function 'name' already exists when you try to create a user-defined function that duplicates an existing routine name in the same database.
The server rejects the CREATE FUNCTION statement to avoid ambiguity during routine lookup. No function body is stored, and execution halts immediately.
The error fires when any routine—UDF or stored function—already uses the target name in the selected database.
MySQL checks the INFORMATION_SCHEMA.ROUTINES table before compiling new code.
Case sensitivity depends on the lower_case_table_names setting, so names that differ only by case may still collide on many systems.
Confirm the conflicting routine with SHOW FUNCTION STATUS or a query against INFORMATION_SCHEMA.ROUTINES. Decide whether to drop, alter, or rename the existing object.
Use DROP FUNCTION IF EXISTS before CREATE FUNCTION, or choose a new, unique routine name.
In multi-schema environments, qualify the function with database name to avoid clashes.
Deployment scripts often rerun CREATE FUNCTION without first cleaning old versions, triggering the error. Adding conditional drops fixes the pipeline.
During migrations, functions moved between databases can keep the same name. Explicitly switch databases with USE other_db or fully qualify the routine name.
Adopt a naming convention that prefixes functions with the team or module name.
This lowers the chance of future collisions.
Include DROP FUNCTION IF EXISTS in every migration file. Version-control functions in Git and review pull requests to spot duplicates early.
Error 1304 ER_PROC_AUTO_REBIND fails when altering routines bound to invalid tables; recompile the routine after fixing table names.
Error 1303 ER_PROC_NOT_FOUND appears when calling a non-existent stored procedure; verify the routine name or database context.
.
A previous deployment already created a UDF with the same identifier, so the new CREATE FUNCTION conflicts immediately.
A standard stored function (not UDF) shares the name in the same schema.
MySQL treats both object types equally for uniqueness.
On Windows or macOS with lower_case_table_names=1, MySQL normalizes routine names to lowercase, making Name() and name() equivalent.
Automated migration tools that run CREATE FUNCTION without conditional DROP repeatedly hit the error on every pipeline execution.
.
No. Dropping a UDF leaves views intact, but calls inside the view will fail until the function is recreated.
On systems with lower_case_table_names=0 and case-sensitive filesystems, MySQL treats routine names as case sensitive. Otherwise, names collide regardless of case.
MySQL lacks ALTER FUNCTION for UDFs. You must DROP FUNCTION and recreate it.
Galaxy’s editor surfaces existing routine names in auto-complete and flags duplicates before you run the query, saving you from runtime errors.