Solved

MySQL errno: 2 when registering UDF

Posted on 2014-11-06
16
316 Views
Last Modified: 2014-11-22
I am getting the error message
Can't open shared library 'xxx.dll' (errno: 2 )
when registering a MySQL UDF with the following command
CREATE AGGREGATE FUNCTION xxx RETURNS REAL SONAME "xxx.dll";

I have my development machine running Windows 7 Pro x64 and MySQL community server 5.0.67 and want to "move" this to a new server running Windows Server 2012 R2 Standard. I have Installed MySQL community server 5.0.67, backed-up and restored the database to the new server. All working fine. I have a few UDFs I created years ago and need them on the new server as well. I copied the .dll files into the \bin directory, but get the above error when trying to register them.

What does error 2 mean?
0
Comment
Question by:DerekWatling
  • 9
  • 7
16 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427808
bin is the wrong folder:
http://dev.mysql.com/doc/refman/5.1/en/create-function-udf.html
The file must be located in the plugin directory. This directory is given by the value of the plugin_dir system variable.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427809
errno 2 means in short: file not found
0
 

Author Comment

by:DerekWatling
ID: 40427841
Keeping in mind that I am running a 5.0 version, where would I verify which is the correct directory? This documentation states the "plugin_dir" system variable was added in MySQL 5.1.2.

I have looked at the Windows system variables and the only thing I can find is that the PATH contains "C:\Program Files\MySQL\MySQL Server 5.0\bin".

Searching the folders on thw working installation these DLLs are only in the "bin" directory.

My directory structure on both installations is very similar:

...
C:\Program Files\MySQL\MySQL Server 5.0
bin
data
    > ...
Docs
include
lib
    > debug
    > opt
share
    > ...
0
 

Author Comment

by:DerekWatling
ID: 40427853
I have found the coressponding 5.0 documentaion which states:
The path name of the plugin directory. This variable was added in MySQL 5.0.67. If the value is nonempty, user-defined function object files must be located in this directory. If the value is empty, the behavior that is used before 5.0.67 applies: The UDF object files must be located in a directory that is searched by your system's dynamic linker.
The version I am using MySQL 5.0.67 :-)
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40427855
http://dev.mysql.com/doc/refman/5.0/en/create-function-udf.html

As of MySQL 5.0.67, the file must be located in the plugin directory. This directory is given by the value of the plugin_dir system variable.

If the value of plugin_dir is empty, the behavior that is used before 5.0.67 applies: The file must be located in a directory that is searched by your system's dynamic linker. For more information, see Section 21.2.2.5, “Compiling and Installing User-Defined Functions”.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427856
:)
0
 

Author Comment

by:DerekWatling
ID: 40427920
I have tried

1.

creating a Windows Environment System Variable
name                 value
plugin_dir          C:\Program Files\MySQL\MySQL Server 5.0\bin
Same error

2.

I then created a plugin subdirectory in "C:\Program Files\MySQL\MySQL Server 5.0\lib" and moved the DLLs in there.
Same error

3.

Removed the system variable
Same error
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427936
did you restart the mysql instance?
can you try to copy the dll into the windows system32 folder?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:DerekWatling
ID: 40428029
No.
Yes.

It probably be only be on Monday, as I am in the middle of something else right now.

Thank you for the help and suggestions so far.
0
 

Author Comment

by:DerekWatling
ID: 40428140
Tried all of the above including putting in Sytem32 with restrting MySQL service inbetween. Consitently getting errno 0 now.
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40428205
it says failed with error 0 ? does not look consistent.
still it is likely a permission issue OR the .dll is 32/64 bit and the mysql is 64/32 bit (not compatbile...)
0
 

Author Comment

by:DerekWatling
ID: 40428242
Both 64bit.
0
 

Accepted Solution

by:
DerekWatling earned 0 total points
ID: 40446737
Using the instructions from http://www.mooreds.com/wordpress/archives/376 as a rough guide, and setting my project target platform as "x64", I re-compiled the udf on the new server. Copied the .dll to "C:\Program Files\MySQL\MySQL Server 5.0\bin" and it works.

My initial attempt at coping the existing dll, which was also compiled as x64 against MySQL 5.0.67, but on Windows Server 2008 R2 just refused to work on Windows Server 2012 R2.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40446934
hard-code stuff :)
0
 

Author Comment

by:DerekWatling
ID: 40447089
What I can say is that the process whs a lot smoother using Visual Studio 2013 Pro than when I originally compiled the udf with Visual C++ Express 2008...
0
 

Author Closing Comment

by:DerekWatling
ID: 40459232
The problem is somewhere in what it was compiled against. Guy sugested a bitness conflict (32 vs 64) which got hime the points.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now