Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2026-05

Connecting to a mariadb server from a Free Pascal Process using Devaun

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Terry A. Haimann

Ok, this all works from Linux Mint running where I am running Mariadb 10.11.14. I ahave also ran this on newer versions of mint w/o issues. But on True Blue Debian systems I haven't gotten it to work.

Ok, yesterday I installed Devaun 6.12.86 on an old laptop (i5-2450m) and installed mariadb 11.8.6. According to the web that version is compatible with Mysql 8.0. I created the database and table and added terry to the grant table.

I then did a fresh compile and tried running it:

fpc ImportCars.pas
Free Pascal Compiler version 3.2.2+dfsg-46 [2025/02/08] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64
Compiling ImportCars.pas
Linking ImportCars
97 lines compiled, 0.3 sec

./ImportCars
An unhandled exception occurred at $00000000004F54E9: EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. $00000000004F54E9
$0000000000482FE5
$000000000047054D

I tried then to install libmysqlclient-dev but according to apt-get that has been discontinued and replaced with either libmariadb-dev or libmariadb-dev-compat. I tried both with the following results:

sudo apt-get install libmariadb-dev
./ImportCars
An unhandled exception occurred at $00000000004F54E9: EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. $00000000004F54E9
$0000000000482FE5
$000000000047054D

I then removed that library and installed the 2nd library.

sudo apt-get remove libmariadb-dev

sudo apt-get install libmariadb-dev-compat

./ImportCars
An unhandled exception occurred at $0000000000483045: EInOutError: TMySQL80Connection can not work with the installed MySQL client version: Expected (8.0), got (3.4.9). $0000000000483045
$000000000047054D

The source code for ImportCars.pas is

Program ImportTow;
Uses SysUtils, StrUtils, db, sqldb, mysql80conn;
{$I /home/terry/Documents/fpc/MysqlConnLib.inc}
{$I /home/terry/Documents/fpc/DbConst.inc}
Var
	CConn:				TSqlConnector;
	CTran: 				TsqlTransaction;
	CQry:					TSqlQuery;
	IFile:				Text;
	Make, Model, Engine, Buffer,
	Trans, Drive, CityStr,
	HwyStr, Yr:				String;
	Sql:					AnsiString;
Function Strip(s: String): String;
Var
	i:		LongInt;
Begin
	i := Pos(' ', s);
	s := Copy(s, i+1, Length(s));
	Strip := s;
End;
Begin
	CConn := CreateConnection('MySQL 8.0', '127.0.0.1', 'TowDB', MyUser, MyPass);
	CreateTransaction(CConn, CTran);
	CQry := GetQuery(CConn, CTran);
	CConn.Open;
	Assign(IFile, 'cars.csv');
	Reset(IFile);
	ReadLn(IFile, Buffer);ReadLn(IFile, Buffer);
	Repeat
		Yr      := ExtractWord(16, Buffer, [',']);
		Yr      := Copy(Yr, 2, Length(Yr)-2);
		Make    := ExtractWord(14, Buffer, [',']);
		Make    := Copy(Make, 2, Length(Make)-2);
		Model   := ExtractWord(13, Buffer, [',']);
		Model   := Copy(Model, 2, Length(Model)-2);
		Model   := Strip(Model);
		Model   := Strip(Model);
		Engine  := ExtractWord(5, Buffer, [',']);
		Engine  := Copy(Engine, 2, Length(Engine)-2);
		Trans   := ExtractWord(12, Buffer, [',']);
		Trans   := Copy(Trans, 2, Length(Trans)-2);
		Drive   := ExtractWord(4, Buffer, [',']);
		Drive   := Copy(Drive, 2, Length(Drive)-2);
		CityStr := ExtractWord(9, Buffer, [',']);
		HwyStr  := ExtractWord(11, Buffer, [',']);
		Sql := 'Insert into CarsTable(Yr, Make, Model, Engine, Drive, Trans, City, Hwy) Values (' +
			QuotedStr(Yr) + ', ' +
			QuotedStr(Make) + ', ' +
			QuotedStr(Model) + ', ' +
			QuotedStr(Engine) + ', ' +
			QuotedStr(Drive) + ', ' +
			QuotedStr(Trans) + ', ' +
			CityStr + ', ' +
			HwyStr + ')';
		// WriteLn('Sql:   ', Sql);
		CQry.Sql.Clear;
		CQry.Sql.Add(Sql);
		CQry.ExecSql;
		CTran.Commit;
		ReadLn(IFile, Buffer);
	Until Eof(IFile);
End.

And /home/terry/Documents/fpc/MysqlConnLib.inc contains:

function GetQuery(Conn: TSqlConnector; Tran: TSqlTransaction) : TSQLQuery;
  var MyQuery : TSQLQuery;
begin
  MyQuery := TSQLQuery.Create(Tran);
  MyQuery.Database := Conn;
  MyQuery.Transaction := Tran;
  GetQuery := MyQuery;
end;
Procedure CreateTransaction(Conn: TSqlConnector;Var Tran: TSqlTransaction);
Begin
  Tran := TSQLTransaction.Create(Tran);
  Tran.Database := Conn;
End;
Function CreateConnection(CType, HostAddr, Database, User, Password: String): TSqlConnector;
Var
	Conn:	TSqlConnector;
Begin
	Conn := TSQLConnector.Create(nil);
	Conn.ConnectorType 	:= CType;
	Conn.Hostname 	:= HostAddr;
	Conn.DatabaseName  	:= Database;
	Conn.UserName		:= User;
	Conn.Password		:= Password;
	CreateConnection 	:= Conn;
End;
Terry A. Haimann

Reply by email

Michael Van Canneyt
to Terry A. Haimann
Terry A. Haimann wrote 42 lines
Ok, this all works from Linux Mint running where I am running Mariadb 10.11.14. I ahave also ran this on newer versions of mint w/o issues. But on True Blue Debian systems I haven't gotten it to work. Ok, yesterday I installed Devaun 6.12.86 on an old laptop (i5-2450m) and installed mariadb 11.8.6. According to the web that version is compatible with Mysql 8.0. I created the database and table and added terry to the grant table. I then did a fresh compile and tried running it: fpc ImportCars.pas Free Pascal Compiler version 3.2.2+dfsg-46 [2025/02/08] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling ImportCars.pas Linking ImportCars 97 lines compiled, 0.3 sec ./ImportCars An unhandled exception occurred at $00000000004F54E9: EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. $00000000004F54E9 $0000000000482FE5 $000000000047054D I tried then to install libmysqlclient-dev but according to apt-get that has been discontinued and replaced with either libmariadb-dev or libmariadb-dev-compat. I tried both with the following results: sudo apt-get install libmariadb-dev ./ImportCars An unhandled exception occurred at $00000000004F54E9: EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. $00000000004F54E9 $0000000000482FE5 $000000000047054D I then removed that library and installed the 2nd library. sudo apt-get remove libmariadb-dev sudo apt-get install libmariadb-dev-compat ./ImportCars An unhandled exception occurred at $0000000000483045: EInOutError: TMySQL80Connection can not work with the installed MySQL client version: Expected (8.0), got (3.4.9). $0000000000483045 $000000000047054D

Set the SkipLibraryVersionCheck property to true, that should avoid this error.

Michael.

Reply by email

Terry A. Haimann

Where and how do I do this?

Message: 1
Date: Mon, 18 May 2026 08:55:30 +0200 (CEST)
From: Michael Van Canneyt
To: "Terry A. Haimann via fpc-pascal"

Subject: Re: [fpc-pascal] Connecting to a mariadb server from a Free Pascal Process using Devaun
Message-ID:
Content-Type: text/plain; charset=US-ASCII; format=flowed

Terry A. Haimann wrote 42 lines
Ok, this all works from Linux Mint running where I am running Mariadb 10.11.14. I ahave also ran this on newer versions of mint w/o issues. But on True Blue Debian systems I haven't gotten it to work. Ok, yesterday I installed Devaun 6.12.86 on an old laptop (i5-2450m) and installed mariadb 11.8.6. According to the web that version is compatible with Mysql 8.0. I created the database and table and added terry to the grant table. I then did a fresh compile and tried running it: fpc ImportCars.pas Free Pascal Compiler version 3.2.2+dfsg-46 [2025/02/08] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling ImportCars.pas Linking ImportCars 97 lines compiled, 0.3 sec ./ImportCars An unhandled exception occurred at $00000000004F54E9: EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. $00000000004F54E9 $0000000000482FE5 $000000000047054D I tried then to install libmysqlclient-dev but according to apt-get that has been discontinued and replaced with either libmariadb-dev or libmariadb-dev-compat. I tried both with the following results: sudo apt-get install libmariadb-dev ./ImportCars An unhandled exception occurred at $00000000004F54E9: EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. $00000000004F54E9 $0000000000482FE5 $000000000047054D I then removed that library and installed the 2nd library. sudo apt-get remove libmariadb-dev sudo apt-get install libmariadb-dev-compat ./ImportCars An unhandled exception occurred at $0000000000483045: EInOutError: TMySQL80Connection can not work with the installed MySQL client version: Expected (8.0), got (3.4.9). $0000000000483045 $000000000047054D

Set the SkipLibraryVersionCheck property to true, that should avoid this error.

Michael.

Terry A. Haimann

Reply by email

Michael Van Canneyt
to Terry A. Haimann

It is a property of the mysql connection class, simply set it to 'True' before connecting.

Michael.

Terry A. Haimann wrote 72 lines
Where and how do I do this? Message: 1 Date: Mon, 18 May 2026 08:55:30 +0200 (CEST) From: Michael Van Canneyt To: "Terry A. Haimann via fpc-pascal" Subject: Re: [fpc-pascal] Connecting to a mariadb server from a Free Pascal Process using Devaun Message-ID: Content-Type: text/plain; charset=US-ASCII; format=flowed On Tue, 12 May 2026, Terry A. Haimann via fpc-pascal wrote: > Ok, this all works from Linux Mint running where I am running Mariadb 10.11.14. I ahave also ran this on newer versions of mint w/o issues. But on True Blue Debian systems I haven't gotten it to work. > > Ok, yesterday I installed Devaun 6.12.86 on an old laptop (i5-2450m) and installed mariadb 11.8.6. According to the web that version is compatible with Mysql 8.0. I created the database and table and added terry to the grant table. > > I then did a fresh compile and tried running it: > > fpc ImportCars.pas > Free Pascal Compiler version 3.2.2+dfsg-46 [2025/02/08] for x86_64 > Copyright (c) 1993-2021 by Florian Klaempfl and others > Target OS: Linux for x86-64 > Compiling ImportCars.pas > Linking ImportCars > 97 lines compiled, 0.3 sec > > ./ImportCars > An unhandled exception occurred at $00000000004F54E9: > EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. > $00000000004F54E9 > $0000000000482FE5 > $000000000047054D > > I tried then to install libmysqlclient-dev but according to apt-get that has been discontinued and replaced with either libmariadb-dev or libmariadb-dev-compat. I tried both with the following results: > > sudo apt-get install libmariadb-dev > ./ImportCars > An unhandled exception occurred at $00000000004F54E9: > EInOutError: Can not load default MySQL library ("libmysqlclient.so.21" or "libmysqlclient.so"). Check your installation. > $00000000004F54E9 > $0000000000482FE5 > $000000000047054D > > I then removed that library and installed the 2nd library. > > sudo apt-get remove libmariadb-dev > > sudo apt-get install libmariadb-dev-compat > > ./ImportCars > An unhandled exception occurred at $0000000000483045: > EInOutError: TMySQL80Connection can not work with the installed MySQL client version: Expected (8.0), got (3.4.9). > $0000000000483045 > $000000000047054D Set the SkipLibraryVersionCheck property to true, that should avoid this error. Michael. -- Terry A. Haimann _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email

Terry A. Haimann

I tried to set my CConn variable as you suggested:

CConn.SkipLibraryVersionCheck := True;

I did this both on a true blue Debian system and the Devaun system

uname -a
Linux debian 6.1.0-33-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.133-1 (2025-04-10) x86_64 GNU/Linux fpc TstAccessingMySql.pas
Free Pascal Compiler version 3.2.2+dfsg-20 [2023/03/30] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64
Compiling TstAccessingMySql.pas
TstAccessingMySql.pas(15,9) Error: identifier idents no member "SkipLibraryVersionCheck" TstAccessingMySql.pas(37) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

The connection variable is defined as a TSqlConnector and if one looks up a TSqlConnector in online documents I do not see any variable called SkipLibraryVersionCheck -- https://www.freepascal.org/docs-html/fcl/sqldb/tsqlconnector.html.

Terry

Terry A. Haimann

Reply by email

Michael Van Canneyt
to Terry A. Haimann
Terry A. Haimann wrote 21 lines
I tried to set my CConn variable as you suggested: CConn.SkipLibraryVersionCheck := True; I did this both on a true blue Debian system and the Devaun system uname -a Linux debian 6.1.0-33-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.133-1 (2025-04-10) x86_64 GNU/Linux fpc TstAccessingMySql.pas Free Pascal Compiler version 3.2.2+dfsg-20 [2023/03/30] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64 Compiling TstAccessingMySql.pas TstAccessingMySql.pas(15,9) Error: identifier idents no member "SkipLibraryVersionCheck" TstAccessingMySql.pas(37) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/bin/ppcx64 returned an error exitcode The connection variable is defined as a TSqlConnector and if one looks up a TSqlConnector in online documents I do not see any variable called SkipLibraryVersionCheck -- https://www.freepascal.org/docs-html/fcl/sqldb/tsqlconnector.html.

That is because it only exists on the mysql connection, since MySQL is the connection presenting all the problems.

The cross-db TSQLConnector does not have this connection-specific property.

Michael.

Reply by email