Home > Software engineering >  Delphi can't connect to MySql, claims libmysql.dll isn't in the path when it is
Delphi can't connect to MySql, claims libmysql.dll isn't in the path when it is

Time:11-07

Before anyone marks this a duplicate, please read to the end, as none of the many similar questions helped.

I've just installed Delphi Community Edition and MySql (recommended download from this link) on Windows 11, but am having trouble connecting Delphi to MySql.

I used MySql Workbench to create a new connection, and created a new database with a table and some sample data.

If I start Delphi and create a new Windows VCL project, then choose Tools -> FireDAC Explorer, then try to expand the connection, I get an error "Cannot load vendor library [libmysql.dll, libmariadb or libmysqld.sll]"

I'm assuming that only libmysql.dll is relevant to me, as I don't use Maria, and don't have the other DLL anywhere on my system. I used sigcheck to check that I indeed have a 64-bit version of the DLL.

I have the same error if I use the Data Explorer in Delphi itself.

I read a lot of questions here about this exact error, but all of the ones I've seen suggest one of two things, neither of which apply here...

  1. Add the DLL's location to the PATH environment variable - I have libmysql.dll in the C:\Program Files\MySQL\MySQL Server 8.0\lib folder, and have added that to my PATH environment variable, but it didn't help. I restarted Delphi, but no joy. I even added a TEdit to my form in Delphi, with the following code...
Edit1.Text := GetEnvironmentVariable('PATH');

This confirmed that I had set the environment variable correctly.

  1. Copy the DLL to the project's bin folder. I tried this as well, and it didn't make any difference. However, as I haven't got as far as trying to connect my code to MySql, I didn't expect this to help. I can't even get Delphi itself to connect.

Anyone any ideas? I know there are a lot of questions about this error, but none of them worked for me.

Thanks

CodePudding user response:

Please check the rest of the error message. Sometimes it specifies the bitness of the DLL you need. It's easy to miss that bit and get the wrong version.

I think MySql comes with a 64-bit DLL, but for some reason I never worked out, Delphi seems to need a 32-bit version. I had to search around and download one from a 3rd-party site, which I don't like, but it did work.

  • Related