Common SQL Errors

MySQL Error 1122 ER_CANT_FIND_UDF: Can't load function - How to Fix and Prevent

Galaxy Team
August 5, 2025

Error 1122 occurs when MySQL cannot locate or load a requested user-defined function (UDF) library.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL Error 1122 ER_CANT_FIND_UDF?

MySQL Error 1122: ER_CANT_FIND_UDF means the server cannot load a referenced user-defined function shared library. Verify the .so/.dll file is in the plugin directory, grant FILE privilege, and run INSTALL FUNCTION with the correct path to resolve the issue.

Error Highlights

Typical Error Message

Can't load function '%s'

Error Type

Plugin/UDF Error

Language

MySQL

Symbol

ER_CANT_FIND_UDF

Error Code

1122

SQL State

Explanation

Table of Contents

What is MySQL Error 1122 ER_CANT_FIND_UDF?

Error 1122 appears with the message "Can't load function '%s'" when MySQL fails to locate or link the shared library that implements a user-defined function (UDF). The server aborts the call and returns SQLSTATE HY000.

The problem surfaces immediately after executing CREATE FUNCTION, INSTALL COMPONENT, or when invoking an existing UDF.

It affects query execution, stored routines, and any application logic that depends on the missing function.

What Causes This Error?

MySQL throws ER_CANT_FIND_UDF when the shared object file (.so on Linux, .dll on Windows) is missing, unreadable, compiled for the wrong CPU architecture, or placed outside the plugin directory defined by plugin_dir.

Incorrect file ownership or restrictive filesystem permissions can block the mysqld process from reading the library, triggering the error even if the file exists.

A mismatched MySQL version or ABI difference causes symbol lookup failures at load time, producing the same error code.

How to Fix MySQL Error 1122 ER_CANT_FIND_UDF

Confirm the UDF library is present in the server's plugin directory (SHOW VARIABLES LIKE 'plugin_dir').

Copy or move the file there and restart MySQL if necessary.

Ensure the mysqld user has read and execute rights on the file and its parent directories (chmod 755 /path/libmyudf.so && chown mysql:mysql /path/libmyudf.so).

Re-install the function with the absolute path if plugin_dir is not used: CREATE FUNCTION myfunc RETURNS INTEGER SONAME 'libmyudf.so';

Recompile the UDF with the same compiler and architecture flags used by your MySQL distribution to resolve symbol or ABI mismatches.

Common Scenarios and Solutions

Upgrading MySQL without rebuilding custom UDFs often breaks binary compatibility.

Rebuild and redeploy the library to fix the error.

Copying production dumps to a staging server that lacks the UDF library triggers 1122 on import. Install or stub out the UDF before restoring the dump.

Best Practices to Avoid This Error

Store all approved UDF libraries in version control and automate deployment so every environment has matching binaries.

Use Galaxy's endorsed-query workflow to eliminate ad hoc CREATE FUNCTION statements.

Central review ensures libraries are compiled, signed, and stored in the correct path.

Related Errors and Solutions

ER_CANT_OPEN_LIBRARY (1126) surfaces when the plugin framework cannot open a shared library at all, usually due to a bad path. Fix by adjusting INSTALL PLUGIN paths or plugin_dir.

ER_CANT_FIND_DL_ENTRY (1124) occurs if MySQL loads the library but cannot find the expected symbol. Recompile the function or correct the symbol name in CREATE FUNCTION.

.

Common Causes

Missing shared library file

The .so or .dll defining the UDF is not present in plugin_dir or the specified absolute path.

Incorrect filesystem permissions

mysqld lacks read or execute permission on the library file or its directories.

ABI or MySQL version mismatch

The library was compiled against headers that differ from the running server, causing symbol resolution failure.

Wrong architecture

Attempting to load a 32-bit library into a 64-bit server (or vice versa) triggers the error.

SELinux or AppArmor restrictions

Security modules block mysqld from accessing files outside approved directories, preventing the UDF from loading.

.

Related Errors

FAQs

Do I need to restart MySQL after copying a UDF library?

No. After placing the library in plugin_dir, a new CREATE FUNCTION or INSTALL COMPONENT command loads it immediately without a restart.

Can I store UDF libraries outside plugin_dir?

Yes, but you must provide the absolute path in CREATE FUNCTION. Keeping all UDFs inside plugin_dir simplifies deployment.

How do I remove a broken UDF?

Execute DROP FUNCTION func_name; then delete the shared library from the filesystem.

Does Galaxy support UDF management?

Galaxy lets teams version and review CREATE FUNCTION statements in endorsed collections, reducing broken UDF deployments.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo