Recent

Author Topic: Cannot connect to MySQL 8.0 using Zeos  (Read 676 times)

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Cannot connect to MySQL 8.0 using Zeos
« on: May 02, 2023, 05:10:24 pm »
I would be grateful for any help in connecting to a MySQL 8.0 database using Zeos. (I don't mind using the built-in database components either, but they had similar problems.)

The set-up is as follows:

OS: Windows 11 Pro 64 bit
Lazarus version: 2.2.2
Date: 2022-05-15
FPC version: 3.2.2
Revision: lazarus_2_2_2
x86_64-win64-win32/win64

Under Configure "Build Lazarus" I have the following:
LCL widget type: win32/win64
Target OS: Win64
Target CPU: x86_64

The MySQL server is on a 64-bit version of Wamp; it is MySQL 8.0.32.
I have taken the libmysql.dll file from the Wamp installation and placed in into the project folder.

So as far as I can see, everything should be working as 64-bit.

The Zeos version is 7.2.14-release. Under the TZConnection properties I have:
Protocol: mysql-5 (I have also tried mysql, but it gives the same error)
Library location points to the libmysql.dll file in the project folder.

I have no problem connecting to this database via Navicat.

When I try to connect with Zeos (by setting "Connected" to True), I get the error: "Client library ... libmysql.dll found but could not be loaded. Check compile-target and library compatibility!"

I've tried everything I can think of, but now I am truly stuck! I would be grateful for any help or pointers for a solution. I was previously able to connect to MySQL 5.6 using the built-in database components, so this is quite a mystery to me. One of the challenges seems to be that it is difficult (impossible?) to find a 32-bit version of the libmysql.dll file for MySQL 8.0. With MySQL (if I remember correctly) I compiled to 32 bits and used the 32-bit version of the dll.

Thank you in advance.

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Cannot connect to MySQL 8.0 using Zeos
« Reply #1 on: May 02, 2023, 09:24:31 pm »
When I try to connect with Zeos (by setting "Connected" to True), I get the error: "Client library ... libmysql.dll found but could not be loaded. Check compile-target and library compatibility!"
This is from the lazarus designer I assume, in this case you have to copy the libmysql.dll in the lazarus folder as well (mind the bitness of the dll to mach that of lazarus) its not your application that does not find the dll its lazarus.
« Last Edit: May 03, 2023, 12:49:24 am by eljo »

marsupilami79

  • New Member
  • *
  • Posts: 38
Re: Cannot connect to MySQL 8.0 using Zeos
« Reply #2 on: May 03, 2023, 01:42:35 pm »
Hello Bruce,

When I try to connect with Zeos (by setting "Connected" to True), I get the error: "Client library ... libmysql.dll found but could not be loaded. Check compile-target and library compatibility!"
This usually means that Zeos cannot load the Library for some (unknown) reason. Possibilities are:
  • If you try to set the active property from Lazarus, your Lazarus might be a 32 bits application while your libmysql.dll ist a 64 bits library.
  • If this happens during runtime, you might have the same problem - your application might be a 32 bits application trying to load a 64 bits dll.
  • Windows may also fail to load the library because of missing dependencies. Check that all dependencies can be found using a dependency walker like this one: https://github.com/lucasg/Dependencies . You also might want to try to use the libmysql.dll in the original location to see if this one can be loaded.

A note about mysql-5 vs. mysql: Please use protocol names without version numbers. We deprecated them and they will not be part of Zeos 8. Zeos 8 will only know "mysql" and it will raise an exception if you try to use mysql-5. The version numbers don't have a meaning with Zeos 7.2 any more.

With best regards,

Jan
Zeos developer

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Cannot connect to MySQL 8.0 using Zeos
« Reply #3 on: May 03, 2023, 08:16:32 pm »
When I try to connect with Zeos (by setting "Connected" to True), I get the error: "Client library ... libmysql.dll found but could not be loaded. Check compile-target and library compatibility!"
This is from the lazarus designer I assume, in this case you have to copy the libmysql.dll in the lazarus folder as well (mind the bitness of the dll to mach that of lazarus) its not your application that does not find the dll its lazarus.

Thank you for that suggextion, eljo. I tried that, but unfortunately it doesn't work.  :(

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Cannot connect to MySQL 8.0 using Zeos
« Reply #4 on: May 03, 2023, 08:19:51 pm »
Hello Bruce,

When I try to connect with Zeos (by setting "Connected" to True), I get the error: "Client library ... libmysql.dll found but could not be loaded. Check compile-target and library compatibility!"
This usually means that Zeos cannot load the Library for some (unknown) reason. Possibilities are:
  • If you try to set the active property from Lazarus, your Lazarus might be a 32 bits application while your libmysql.dll ist a 64 bits library.
  • If this happens during runtime, you might have the same problem - your application might be a 32 bits application trying to load a 64 bits dll.
  • Windows may also fail to load the library because of missing dependencies. Check that all dependencies can be found using a dependency walker like this one: https://github.com/lucasg/Dependencies . You also might want to try to use the libmysql.dll in the original location to see if this one can be loaded.

A note about mysql-5 vs. mysql: Please use protocol names without version numbers. We deprecated them and they will not be part of Zeos 8. Zeos 8 will only know "mysql" and it will raise an exception if you try to use mysql-5. The version numbers don't have a meaning with Zeos 7.2 any more.

With best regards,

Jan

Thank you, Jan, for those helpful comments.

For now, I have managed to get the connection working by switching over to MariaDB. I have seen on the Zeos forum that I could possible use the MariaDB library to access the MySQL database. When I have more time I will experiment a bit with the different possibilities. I gather from around the web (and other reading) that the MySQL drivers can be quite fussy as to versions, etc.

Best regards
Bruce

 

TinyPortal © 2005-2018