How to Fix MySQL Error 1122 (ER_CANT_FIND_UDF)
You get mysql error 1122 when the database cannot load a user-defined function. You fix it by placing the valid shared library file in the plugin folder. In MySQL, this failure maps to symbol ER_CANT_FIND_UDF and SQLSTATE HY000. The server returns the message Can't load function '%s' to your client. This stops your query right away and blocks the app from running custom logic. Teams see this issue after server upgrades, host moves, or file permission changes. What causes mysql error 1122 in y
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You get mysql error 1122 when the database cannot load a user-defined function. You fix it by placing the valid shared library file in the plugin folder.
In MySQL, this failure maps to symbol ER_CANT_FIND_UDF and SQLSTATE HY000. The server returns the message Can't load function '%s' to your client. This stops your query right away and blocks the app from running custom logic. Teams see this issue after server upgrades, host moves, or file permission changes.
What causes mysql error 1122 in your database
MySQL lets you add custom code through compiled shared library files. When a query calls that function, the engine looks up the library in memory. If the engine cannot load the function symbol, it throws mysql error 1122. Several system issues cause the database engine to fail during this lookup step.
First, the shared library file might be missing from the designated plugin folder. This happens often when teams move a database to a new server host. The data tables move over, but the compiled library files get left behind. Replica nodes also hit this error when admins forget to sync plugin files.
Second, the operating system user running MySQL might lack read and execute permissions. If the database process cannot read the file, it cannot load the function. Security tools on Linux hosts can also block the database from reading outside files.
Third, the compiled library might not match your current server architecture. For example, a 32-bit library will fail to load inside a 64-bit database engine. A typo in the function name during registration also triggers the exact same error. Finally, missing C initialization symbols inside the compiled code will stop the load process.
How to diagnose and fix the failure in production
Start your check by reading the database error log for system messages. The log shows the exact file path and the reason the load failed. Next, check the active plugin directory path inside your database settings. Make sure the shared library file sits inside that exact folder on the host.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Do not fix file access issues by granting full root privileges to everyone. Instead, give the specific database system user read and execute rights on that file. Keep write permissions restricted so bad actors cannot swap the binary file with malware.
If the file is present and readable, check the exported symbols in the binary. Make sure the function name in your query matches the C code symbol case. Verify that the library includes the required initialization and cleanup functions for the engine. Also confirm that all linked system libraries exist on the host machine.
After you place the right file and fix permissions, reload the function registration. Drop the broken function entry and create it again using an admin role. Test the function with a simple query before you open traffic to the app.
How to prevent function loading failures across hosts
Manual file copies on production hosts lead to drift and broken database queries. Store your compiled library files in version control or a secure package store. Use automated deployment scripts to push the library to every replica node at once. These scripts should set the exact file owner and permission bits every time.
Test all custom functions in a staging setup before you upgrade the database engine. Major engine updates can change how internal plugins and functions load into memory. If a custom function only does basic text math, rewrite it as a stored function. Native stored functions live inside the database catalog and move with normal backups. You should also restrict who can register custom functions in production databases. Limit function creation rights to senior database admins to keep the server safe.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.
Frequently asked questions
What does ER_CANT_FIND_UDF mean in MySQL?
ER_CANT_FIND_UDF is the official symbol for error code 1122 with SQLSTATE HY000. It means the server cannot find or initialize a requested user-defined function.
Can a MySQL upgrade trigger mysql error 1122?
Yes, an upgrade can change the plugin folder path or require a new binary build. Check that your compiled library sits in the new folder and matches the engine.
Do managed cloud databases support custom C functions?
Most managed cloud database services block custom C libraries for host safety reasons. You must use native SQL stored functions instead when running on managed cloud hosts.
Related guides
In this post