MySQL cannot load a required shared library or plugin, returning ER_CANT_OPEN_LIBRARY (error 1126).
MySQL Error 1126: ER_CANT_OPEN_LIBRARY appears when the server fails to load a required shared library or plugin. Incorrect plugin_dir, missing .so/.dll files, or inadequate file permissions usually cause it. Reinstall the library, correct the path, and grant read-execute access to resolve the issue.
Can't open shared library '%s' (errno: %d %s)
MySQL raises error 1126 with the message "Can't open shared library '%s' (errno: %d %s)" when it cannot load a dynamic library or plugin at startup or during a CREATE FUNCTION, INSTALL PLUGIN, or LOAD DATA operation.
The server relies on the operating system's dynamic linker, so any path, permission, or dependency issue blocks the load and triggers this error.
Fixing the problem quickly is important because MySQL may refuse to start, skip loading essential plugins such as authentication or storage engines, and leave applications unusable until the library issue is resolved.
The library file is missing from the directory specified by the plugin_dir system variable or hard-coded path in CREATE FUNCTION.
A filename typo or version mismatch also prevents loading and throws error 1126.
File permissions often block the MySQL daemon (mysqld) from reading or executing the .so or .dll file. SELinux or AppArmor profiles can further restrict access and surface the same error code.
Unresolved dependent libraries at the OS level cause the dynamic loader to fail.
ldd on Linux or Dependency Walker on Windows reveals missing libc, libstdc++, or OpenSSL versions that break plugin loading.
Verify plugin_dir with SHOW VARIABLES LIKE 'plugin_dir'; and confirm the target .so/.dll file exists. Copy or reinstall the plugin package if it is missing.
Correct file permissions by running chmod 755 libmyplugin.so and chown mysql:mysql libmyplugin.so. Ensure mysqld has execute rights.
Resolve dependent libraries.
On Linux, run ldd libmyplugin.so and install any "not found" packages with the system package manager. On Windows, place required DLLs in the same folder or a directory in the PATH.
After an OS upgrade, OpenSSL or glibc versions change and existing plugins fail to link. Recompile the plugin against new headers or install MySQL’s matching plugin build.
When deploying on Alpine Linux, musl libc replaces glibc, so precompiled Oracle or Percona plugins refuse to load.
Use community builds compiled for musl or switch to a glibc-based image.
Pin MySQL and plugin versions in configuration management tools and container images.
Always deploy compatible binaries together to avoid mismatch.
Automate validation with a startup script that runs INSTALL PLUGIN IF NOT EXISTS and logs failures before traffic reaches the database.
Monitor the MySQL error log and trigger alerts on ER_CANT_OPEN_LIBRARY appearances, enabling proactive remediation.
Error 1127 (ER_DYNAMIC_SQL_ERROR) often follows 1126 when a UDF fails to load and a statement still references it.
Remove or fix the UDF.
Error 1524 (ER_PASSWORD_NO_MATCH) may appear if the authentication plugin failed to load due to 1126, causing user logins to break. Install the auth plugin and retry.
.
plugin_dir points to an outdated or wrong directory so mysqld cannot locate the requested library.
The plugin package was not installed on the host or was deleted during a cleanup, leaving MySQL with a dangling reference.
The MySQL service user lacks read or execute rights on the library file, blocking the operating system loader.
The library itself links to other shared objects that are absent or incompatible on the system.
SELinux, AppArmor, or antivirus software intercepts mysqld’s attempt to load the file and denies it.
.
No. Windows shows the same error when MySQL cannot load a DLL. Path and permission concepts apply across platforms.
Ignoring it risks runtime failures. Missing storage engines or authentication plugins can break queries and connections later.
Galaxy surfaces real-time error logs inside its SQL editor, letting engineers spot plugin load failures immediately. Version-controlled configuration in Galaxy keeps plugin_dir settings consistent across environments.
No. Reinstalling the correct binary or adding missing dependencies fixes most cases. Recompile only when plugin source and server version mismatch.