Recent

Author Topic: Connecting to MariaDB 10.6 or 10.11  (Read 1779 times)

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Connecting to MariaDB 10.6 or 10.11
« on: February 28, 2024, 08:19:43 pm »
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

  • Hero Member
  • *****
  • Posts: 5150
  • My goal: build my own game engine using Lazarus
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #1 on: February 29, 2024, 06:28:44 am »
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.html#msg336983

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #2 on: February 29, 2024, 08:07:19 am »
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.
« Last Edit: February 29, 2024, 12:03:56 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #3 on: February 29, 2024, 08:38:42 am »
Wasn't there a recommendation to use "SkipLibraryCheck" for MariaDB?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #4 on: February 29, 2024, 08:53:32 am »
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.
« Last Edit: February 29, 2024, 09:37:17 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #5 on: February 29, 2024, 11:16:56 am »
Found it:
mysqlconn.inc - Line 572 pp
Code: Pascal  [Select][+][-]
  1. procedure TConnectionName.DoInternalConnect;
  2. var
  3.   FullVersion: string;
  4. begin
  5.   InitialiseMysql;
  6.   if not SkipLibraryVersionCheck then
  7.     begin
  8.     FullVersion:=strpas(mysql_get_client_info());
  9.     // Version string should start with version number:
  10.     // Note: in case of MariaDB version mismatch: tough luck, we report MySQL
  11.     // version only.
  12.     if (pos(MySQLVersion, FullVersion) <> 1) and
  13.        (pos(MariaDBVersion, FullVersion) <> 1) then
  14.       Raise EInOutError.CreateFmt(SErrVersionMisMatch,[ClassName,MySQLVersion,FullVersion]);
  15.     end;  
  16.   inherited DoInternalConnect;
  17.   ConnectToServer;
  18.   SelectDatabase;
  19. end;

Quote
// Note: in case of MariaDB version mismatch: tough luck, we report MySQL
    // version only.
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #6 on: February 29, 2024, 11:23:39 am »
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?
If with "Client Library" you mean the dll/so --> From MySQL-Homepage? --> https://dev.mysql.com/downloads/c-api/
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #7 on: February 29, 2024, 03:13:53 pm »
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

  • Hero Member
  • *****
  • Posts: 1076
    • http://www.cdbc.dk
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #8 on: February 29, 2024, 03:31:43 pm »
Hi
Rename the DLL to  'libmysql.dll'?!?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #9 on: February 29, 2024, 03:39:42 pm »
Rename 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

  • Hero Member
  • *****
  • Posts: 1076
    • http://www.cdbc.dk
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #10 on: February 29, 2024, 03:45:56 pm »
Hi
How about libmysql-5.7.41.0 -> libmysql.dll
In *nix & linux we do symlinks for that...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #11 on: February 29, 2024, 04:04:12 pm »
Hi Benny

The file is already called libmysql.dll.

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #12 on: February 29, 2024, 04:04:55 pm »
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
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #13 on: February 29, 2024, 04:45:21 pm »
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

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!
« Last Edit: February 29, 2024, 04:47:05 pm by bruce.button »

bruce.button

  • Jr. Member
  • **
  • Posts: 59
Re: Connecting to MariaDB 10.6 or 10.11
« Reply #14 on: February 29, 2024, 04:58:15 pm »
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.

 

TinyPortal © 2005-2018