libmysqld libmariadbd zeos lazarus / 16-Databases ---------------------------------------------------------------------- pcurtis · 2022-03-12 13:45 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. ---------------------------------------------------------------------- Thaddy · 2022-03-12 14:38 Quote from: pcurtis on March 12, 2022, 02:45:58 pmHas 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. ---------------------------------------------------------------------- pcurtis · 2022-03-12 15:49 Both embedded versions are depreciated. QuoteThe 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 QuoteStarting 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. ---------------------------------------------------------------------- marsupilami79 · 2022-03-13 15:53 Quote from: pcurtis on March 12, 2022, 04:49:50 pmAnyway 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. ---------------------------------------------------------------------- pcurtis · 2022-03-13 17:40 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 ---------------------------------------------------------------------- marsupilami79 · 2022-03-14 21:24 So - the following kinda works for me - it doesn't throw any exceptions at me: 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 TForm1.Button1Click(Sender: TObject);begin  ZConnection1.Protocol := 'mysqld-5';  ZConnection1.ClientCodepage := 'utf8mb4';  ZConnection1.LibraryLocation := 'D:\Projects\Zeos\MySQL\mysql-5.7.36-win32\lib\libmysqld.dll';  ZConnection1.User := 'root';// When activating the following line, I get an 'unknown database' error. So maybe the system database needs to be initialized.//  ZConnection1.Database := 'mysql';  ZConnection1.Pro perties.Add('ServerArgument000=-- datadir=D:\Projekte\Zeos\MySQL\data');  ZConnection1.Properties.Add('S erverArgument001=--lc_messages_dir=D:\Projects\Zeos\MySQL\mysql- 5.7.36-win32\share\english');  ZConnection1.Connect;end; 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. ---------------------------------------------------------------------- pcurtis · 2022-03-15 06:55 Thanks. I will take a look and let you know. ---------------------------------------------------------------------- pcurtis · 2022-03-18 15:07 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 Quotemariadbd.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 ---------------------------------------------------------------------- marsupilami79 · 2022-03-23 09:25 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.