Recent

Author Topic: libmysqld libmariadbd zeos  (Read 2486 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
libmysqld libmariadbd zeos
« on: March 12, 2022, 02:45:58 pm »
Has anyone got a simple example of connecting to either MySQL or MariaDB embedded server using zeos. I know they're depreciated but I need it for a project.

Thanks.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Thaddy

  • Hero Member
  • *****
  • Posts: 18666
  • Jungle wars. And failing health it seems.
Re: libmysqld libmariadbd zeos
« Reply #1 on: March 12, 2022, 03:38:47 pm »
Has anyone got a simple example of connecting to either MySQL or MariaDB embedded server using zeos. I know they're depreciated but I need it for a project.

Thanks.
"They", MySQL and MariaDb, are not deprecated, they are both mainstream and largely compatible, to my mind just Zeos is (or should be anyway, although it is also maintained - a bit). For the former two I have many examples, using fcl-db, fcl-net and fcl-web, but I haven't used Zeos for years. So can't help you there.

What I suspect, though, that it can not keep up with the versioning of the other two.
« Last Edit: March 12, 2022, 03:50:44 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: libmysqld libmariadbd zeos
« Reply #2 on: March 12, 2022, 04:49:50 pm »
Both embedded versions are depreciated.

Quote
The libmysqld embedded server library is deprecated as of MySQL 5.7.19 and is removed in MySQL 8.0.
https://dev.mysql.com/doc/refman/5.7/en/libmysqld.html

Quote
Starting with MariaDB 10.5 the embedded server library and related test binaries are no longer part of binary tarball release archives.
https://mariadb.com/kb/en/embedded-mariadb-interface/

Anyway I would appreciate if you could share a sample of how to connect to an EMBEDDED server. Connecting to the normal server versions is no problem.
« Last Edit: March 12, 2022, 05:18:21 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

marsupilami79

  • New Member
  • *
  • Posts: 43
Re: libmysqld libmariadbd zeos
« Reply #3 on: March 13, 2022, 04:53:29 pm »
Anyway I would appreciate if you could share a sample of how to connect to an EMBEDDED server. Connecting to the normal server versions is no problem.
Hello pcurtis, Zeos automatically calls mysql_library_init if it is exported by the client library. So you should be ready to go if you point the ZConnection.LibraryLocation property to libmysqld.dll / libmysqld.so. I assume you have to keep the HostName property empty because otherwise libmysqld seems to behave like a regular client library.
If there are problems, let me know.

Contradicting Thaddys assumption, Zeos is still extended and maintained.
Zeos developer

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: libmysqld libmariadbd zeos
« Reply #4 on: March 13, 2022, 06:40:58 pm »
Ive been using ZEOS since D7, I like it and am happy it is maintained.

I have tried what you suggested and it still doesnt connect.

I have this

Laz 2.2.0
Win 10
Zeos 7.2.14
Mariabb 10.5.15

I have created \bin, \data, \share directories and copied libmariadb.dll and server.dll to the bin directory, errmsg.sys to the \share directory.
In the \data directory I have no databases only my.ini

[mysqld]
bind-address = 127.0.0.1
port=3307

I have another server on 3306

I have set port to 3307, user and password are empty, protocol=Mariadb 10.0, librarylocation=C:\Projects\libmariadb\bin\libmariadb.dll

and it still wont connect.

Please help
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

marsupilami79

  • New Member
  • *
  • Posts: 43
Re: libmysqld libmariadbd zeos
« Reply #5 on: March 14, 2022, 10:24:23 pm »
So - the following kinda works for me - it doesn't throw any exceptions at me:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   ZConnection1.Protocol := 'mysqld-5';
  4.   ZConnection1.ClientCodepage := 'utf8mb4';
  5.   ZConnection1.LibraryLocation := 'D:\Projects\Zeos\MySQL\mysql-5.7.36-win32\lib\libmysqld.dll';
  6.   ZConnection1.User := 'root';
  7. // When activating the following line, I get an 'unknown database' error. So maybe the system database needs to be initialized.
  8. //  ZConnection1.Database := 'mysql';
  9.   ZConnection1.Properties.Add('ServerArgument000=--datadir=D:\Projekte\Zeos\MySQL\data');
  10.   ZConnection1.Properties.Add('ServerArgument001=--lc_messages_dir=D:\Projects\Zeos\MySQL\mysql-5.7.36-win32\share\english');
  11.   ZConnection1.Connect;
  12. end;
  13.  
Since I get an error when trying to connect to the mysql database, I assume that the system tables have to be initialized somehow. Honestly I have no clue on how to operate an embeded MySQL server. I didn't test this with MariaDB (yet).

Note 1: The ServerArgumentXXX parameters only need to start with "ServerArgument". If you have numbers following or not is up to you. Letters and other symbols could be used too.

Note 2: This doesn't work on Zeos 8 (yet), so you might want to stay with Zeos 7.2 for now. Zeos 8 will need some bugfixes for these things to work correctly.
Zeos developer

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: libmysqld libmariadbd zeos
« Reply #6 on: March 15, 2022, 07:55:06 am »
Thanks. I will take a look and let you know.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: libmysqld libmariadbd zeos
« Reply #7 on: March 18, 2022, 04:07:31 pm »
Ok. As my interest is more MariaDB than MySQL I looked more into MariaDB. Due to the fact MariaDB doesn't include an embedded version I have been looking at execting a standalone server using mariadbd.exe and am having certain success.

Yes you are right, the table mysql has to be initialized.

I have only one issue now. How can I tell ZConnection which named pipe I want to connect to?

As before I have two server 127.0.0.1 port 3306 (this server also has a named pipe MySQL)
the second server is executed with

Quote
mariadbd.exe --console --default-storage-engine=MyISAM --named-pipe --skip-grant-tables --skip-networking --socket=MariaDB --skip-innodb

Both server are running at the same time on the same machine. Using HeidiSQL I can connect to both servers at the same. The first by IP, and the second by named pipe (in this case MariaDB).

How can I tell ZConnection which namedpipe to use? (It always connects to MySQL on the first server)

I have this in properties:-

MYSQL_OPT_NAMED_PIPE
MYSQL_OPT_PROTOCOL=3
MARIADB_OPT_UNIXSOCKET=MariaDB
« Last Edit: March 18, 2022, 06:22:46 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

marsupilami79

  • New Member
  • *
  • Posts: 43
Re: libmysqld libmariadbd zeos
« Reply #8 on: March 23, 2022, 10:25:10 am »
Ok - this is a whole different story ;) I remembered that there was a thread with somebody who wanted to achieve the same. So I digged it out in the Zeos forums: https://zeoslib.sourceforge.io/viewtopic.php?f=40&t=135443.
According to this post one cannot connect using named pipes currently. I didn't get around to implementing it yet. Maybe I can get to do that during the weekend.

What should work, are shared memory connections (MYSQL_OPT_PROTOCOL=4) though. Maybe it makes sense to look into that. There are some other options to specify for this to work. I never tested it though.
Zeos developer

 

TinyPortal © 2005-2018