Connecting to MariaDB 10.6 or 10.11 lazarus / 16-Databases ---------------------------------------------------------------------- bruce.button · 2024-02-28 19:19 Which connector should I use to connect a Lazarus project to a MariaDB database (using MariaDB version 10.6 or 10.11)? The closest I can see is MySQL 80. Is there still enough compatibility between MariaDB and MySQL in the latest versions for the MySQL connector to work properly with MariaDB? And where would I obtain the correct client library? ---------------------------------------------------------------------- Handoko · 2024-02-29 05:28 I don't know how to use Lazarus to connect MariaDB but I found this information, which maybe useful to you: https://forum.lazarus.freepascal.org/index.php/topic,47140.msg336983.h tml#msg336983 ---------------------------------------------------------------------- Thaddy · 2024-02-29 07:07 At the moment you should use 57. since it looks like 80 needs a small patch in the defines, but should also work, since 57andup is defined for 80, which should work with MariaDb too. I use 57  on Linux64. About the client: you don't need one. The connector IS the client. ---------------------------------------------------------------------- Zvoni · 2024-02-29 07:38 Wasn't there a recommendation to use "SkipLibraryCheck" for MariaDB? ---------------------------------------------------------------------- Thaddy · 2024-02-29 07:53 57 works with MariaDb 10.x and is aliased in mysqlconn.inc I can't remember I needed SkipLibraryCheck. Will look it up. It is on a running server. [edit] I did and I also seem to have aliased the client lib. ---------------------------------------------------------------------- Zvoni · 2024-02-29 10:16 Found it: mysqlconn.inc - Line 572 pp Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TConnectionName.DoInternalConnect;var  FullVersion: string;begin  InitialiseMysql;  if not SkipLibraryVersionCheck then    begin    FullVersion:=strpas(mysql_get_client_info());    // Version string should start with version number:    // Note: in case of MariaDB version mismatch: tough luck, we report MySQL    // version only.    if (pos(MySQLVersion, FullVersion) <> 1) and       (pos(MariaDBVersion, FullVersion) <> 1) then      Raise EInOutError.C reateFmt(SErrVersionMisMatch,[ClassName,MySQLVersion,FullVersion]);  end;    inherited DoInternalConnect;  ConnectToServer;  SelectDatabase;end; Quote// Note: in case of MariaDB version mismatch: tough luck, we report MySQL     // version only. ---------------------------------------------------------------------- Zvoni · 2024-02-29 10:23 Quote from: bruce.button on February 28, 2024, 08:19:43 pmWhich connector should I use to connect a Lazarus project to a MariaDB database (using MariaDB version 10.6 or 10.11)? The closest I can see is MySQL 80. Is there still enough compatibility between MariaDB and MySQL in the latest versions for the MySQL connector to work properly with MariaDB? And where would I obtain the correct client library? If with "Client Library" you mean the dll/so --> From MySQL-Homepage? --> https://dev.mysql.com/downloads/c-api/ ---------------------------------------------------------------------- bruce.button · 2024-02-29 14:13 Thank you for all the guidance and instructions. Unfortunately I am not able to connect. I am using the following: OS: Windows 11 MariaDB 10.6.16 server running on Linux Ubuntu 22.04 accessed via LAN In Lazarus, I have dropped a TMySQL57Connection object onto the form. Settings are as follows (see screenshot): Hostname: [ip address of server on LAN] Port: [Port of MariaDB on server] Username and password entered Database name entered I have copied libmysql.dll to the project folder. It is a dll for version 5.7.41.0 which I obtained from a Wamp server installation. (I was unable to find a dll file on the MySQL website.) When I try to connect to the server using the Connected property of the TMySQL57Connection object in the Object Inspector I get the error      "Can not load default MySQL library 'libmysql.dll' or 'libmysql.dll'). Check your installation." I have tried using the MariaDB client library (libmariadb.dll), which I have previous found to work, even with a MySQL database, but it gives the same error. It doesn't matter whether I tick "SkipLibraryVersionCheck" or not. In both cases I get the same error. I would be most grateful for guidance on fixing this problem. Thank you! ---------------------------------------------------------------------- cdbc · 2024-02-29 14:31 Hi Rename the DLL to  'libmysql.dll'?!? Regards Benny ---------------------------------------------------------------------- bruce.button · 2024-02-29 14:39 Quote from: cdbc on February 29, 2024, 03:31:43 pmRename the DLL to  'libmysql.dll'?!? Hi Benny I presume you mane that I should rename libmariadb.dll to libmysql.dll. I have tried that, but it does not work, unfortunately. ---------------------------------------------------------------------- cdbc · 2024-02-29 14:45 Hi How about libmysql-5.7.41.0 -> libmysql.dll In *nix & linux we do symlinks for that... Regards Benny ---------------------------------------------------------------------- bruce.button · 2024-02-29 15:04 Hi Benny The file is already called libmysql.dll. ---------------------------------------------------------------------- Zvoni · 2024-02-29 15:04 OK, Is your Lazarus 32 or 64-Bit? Are you targeting 32 or 64 Bit? https://dev.mysql.com/downloads/mysql/ Here you have to choose the correct package AND run the Installer Next: Apparently, MS Visual C++ 2013 Redistributable x64 has to be installed. (resp. the 32-Bit if 32-Bit) No idea if it's shipped with the bundle ---------------------------------------------------------------------- bruce.button · 2024-02-29 15:45 Quote from: Zvoni on February 29, 2024, 04:04:55 pmOK, Is your Lazarus 32 or 64-Bit? Are you targeting 32 or 64 Bit? https://dev.mysql.com/downloads/mysql/ Here you have to choose the correct package AND run the Installer Next: Apparently, MS Visual C++ 2013 Redistributable x64 has to be installed. (resp. the 32-Bit if 32-Bit) No idea if it's shipped with the bundle Lazarus is 64-bit. (Here is the "About" information: Lazarus 3.2 (rev lazarus_3_2) FPC 3.2.2 x86_64-win64-win32/win64.) As far as I can see I am targeting 32 bit. (Win 32 gui application is checked in Project Compiler options.) I know I have had problems before with the 32 vs 64 bit versions of the client libraries. So maybe that is the problem. But it seems crazy to have to install the whole MySQL server on my PC just to get the dll file. I am hesitant to do that for fear that it will interfere with other programs on my computer — especially if I am installing a 32-bit server on a 64-bit OS. Is there no way to just download the dll file? Thanks again for the help. I appreciate it! ---------------------------------------------------------------------- bruce.button · 2024-02-29 15:58 It would actually be easier to just target 64 bits. Do I just uncheck "Win 32 gui application" in Project Compiler options? If I do that, then a console window is opened before opening the application window. That also doesn't solve the dll client library problem. ---------------------------------------------------------------------- bruce.button · 2024-02-29 17:07 Here are some further findings: I can connect easily to the database server using the Zeos library. In the TZConnection object I just specify the usual parameters, choose MariaDB-10 as the protocol and point the connection to the client library dll. Using libmariadb.dll I have no trouble connecting to the database. It doesn't matter whether I change the compile options by checking or unchecking "Win 32 gui application". My conclusion is that there is no problem with the client library, but with the TMySQL57Connection object. I gather that others use it with success (mainly on Linux?), but I have not been able to use it successfully, even with a MySQL database server. I was reluctant to use Zeos because its development seems to have stalled; the latest stable release (7.2.14) is from July 2021, nearly three years ago. But if that's all that works, it seems there is no choice. I'd be grateful for perspectives on this point from seasoned users of Lazarus and MySQL/MariaDB. ---------------------------------------------------------------------- dseligo · 2024-02-29 20:17 Quote from: bruce.button on February 29, 2024, 04:45:21 pmAs far as I can see I am targeting 32 bit. (Win 32 gui application is checked in Project Compiler options.) Option 'Win32 gui application (-WG)' is not to choose between 32 and 64 bit target. If you want to make console application then uncheck this. Look above this option, at 'Target OS (-T)' and 'Target CPU family (-P)'. If you have '(Default)' in both and Lazarus is 64-bit then you are targeting 64 bit. You target 64 bit also if target OS is Win64 and target CPU family is x86_64. If target OS is Win32 and target CPU family is i386 then you are targeting 32 bit. ---------------------------------------------------------------------- dseligo · 2024-02-29 20:23 Quote from: bruce.button on February 29, 2024, 06:07:37 pmI was reluctant to use Zeos because its development seems to have stalled; the latest stable release (7.2.14) is from July 2021, nearly three years ago. But if that's all that works, it seems there is no choice. I think version 8 is under development. QuoteI'd be grateful for perspectives on this point from seasoned users of Lazarus and MySQL/MariaDB. I use Zeos with MariaDB without problems for years. ---------------------------------------------------------------------- bruce.button · 2024-03-02 12:53 Quote from: dseligo on February 29, 2024, 09:17:21 pmQuote from: bruce.button on February 29, 2024, 04:45:21 pmAs far as I can see I am targeting 32 bit. (Win 32 gui application is checked in Project Compiler options.) Option 'Win32 gui application (-WG)' is not to choose between 32 and 64 bit target. If you want to make console application then uncheck this. Look above this option, at 'Target OS (-T)' and 'Target CPU family (-P)'. If you have '(Default)' in both and Lazarus is 64-bit then you are targeting 64 bit. You target 64 bit also if target OS is Win64 and target CPU family is x86_64. If target OS is Win32 and target CPU family is i386 then you are targeting 32 bit. Thank you for that information. That is helpful. ---------------------------------------------------------------------- bruce.button · 2024-03-02 13:00 Quote from: dseligo on February 29, 2024, 09:23:49 pmQuote from: bruce.button on February 29, 2024, 06:07:37 pmI was reluctant to use Zeos because its development seems to have stalled; the latest stable release (7.2.14) is from July 2021, nearly three years ago. But if that's all that works, it seems there is no choice. I think version 8 is under development. QuoteI'd be grateful for perspectives on this point from seasoned users of Lazarus and MySQL/MariaDB. I use Zeos with MariaDB without problems for years. Thank you, dseligo. My conclusion is that Zeos is the way to go, especially since they have just released a stable version 8.0 with feature additions and bug fixes. I can connect to various databases easily and the library seems to work well.