MySQL client version: Expected (5.6) , got (5.7.16) lazarus / 16-Databases ---------------------------------------------------------------------- vasskalinin · 2016-12-02 23:52 Is there a way I can use MySQL 5.7 with Lazarus? I use the last Lazarus versions for both Linux (1.6.0) and Windows (1.6.2) and there doesn't seem to be any support for the MySQL 5.7 client library, and I get an error when I try to connect with my database. Plus, I can't find the package libmysqlclient-dev version 5.6 or below... ---------------------------------------------------------------------- vasskalinin · 2016-12-03 05:58 Apparently I solved it, at least on windows. I downloaded an old version of MySQL from right here: http://dev.mysql.com/downloads/mysql/5.0.html and then when it asked for DLLs I copied then from the /lib/ folder in the zip and moved them to System32, and that's it, I think. ---------------------------------------------------------------------- Thaddy · 2016-12-03 07:36 MySQL 5.7 is in fpc trunk. You can use the interface unit in 3.0.x as well. ---------------------------------------------------------------------- vasskalinin · 2016-12-03 15:51 How exactly I do that? Thank you. ---------------------------------------------------------------------- marcov · 2016-12-03 16:18 The connection component holds the version. Switch the 5.6 component for a 5.7 one. ---------------------------------------------------------------------- vasskalinin · 2016-12-03 17:28 Quote from: marcov on December 03, 2016, 05:18:40 pmThe connection component holds the version. Switch the 5.6 component for a 5.7 one. There is no 5.7 component ---------------------------------------------------------------------- Thaddy · 2016-12-03 17:46 Sigh. Yes there is. In trunk. As I wrote. In package fcl-db. /packages/fcl-db/src/sqldb/mysql/mysql57conn.pas ---------------------------------------------------------------------- vasskalinin · 2016-12-03 21:14 Quote from: Thaddy on December 03, 2016, 06:46:17 pmSigh. Yes there is. In trunk. As I wrote. In package fcl-db. /packages/fcl- db/src/sqldb/mysql/mysql57conn.pas And... How do I use it with lazarus? ---------------------------------------------------------------------- vrull · 2016-12-04 21:44 I asked same question not long ago. Just add "mysql57conn" to uses  list and that it. ---------------------------------------------------------------------- vasskalinin · 2016-12-05 02:10 Quote from: vrull on December 04, 2016, 10:44:51 pmI asked same question not long ago. Just add "mysql57conn" to uses  list and that it. And it works only on runtime? Taking note, I used mysql 5.5 on my system... ---------------------------------------------------------------------- vrull · 2016-12-05 07:24 Yes, I create connections dynamically at runtime. The full code is below, it is a public function in DataModule: 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 unit uDM; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, sqlite3conn, sqldb, sqldblib, IBConnection, mysql40conn,  mysql56conn, mysql57conn, mysql55conn, mssqlconn, db, LazFileUtils; const  connList : array [0..4] of string =     ('SQLite3', 'MySQL 4.0', 'MySQL 5.5', 'MySQL 5.6', 'MS SQL');type   { TDM }   TDM = class(TDataModule)    dsDataSource: TDataSource;    qSQLQuery: TSQLQuery;    SQLDBLibraryLoader: TSQLDBLibraryLoader;    SQLTransaction: TSQLTransaction;    SQLTranUpdate: TSQLTransaction;    connSQL : TSQLConnection;    procedure DataModuleCreate(Sender: TObject);    procedure DataModuleDestroy(Sender: TObject);  private    FconnType: integer;    paramList : TStringList;    procedure SetconnType(AValue: integer);  public    function GetCLParameter(const paramName : string; const defValue : string = '') : string;    function FindConfigName(const fName : string) : string;    function ConnectToDatabase(var SQLConnection : TSQLConnection; const test : boolean = false) : boolean;    property connType : integer read FconnType write SetconnType;  end; var  DM: TDM; implementation{$R *.lfm}uses uGlobal; // this part is skipped..... // ConnectToDatabase is to create a new connection depending on what connection type is in the configuration file// parameters: SQLconnection returns working connection//  test is true on program start to find out if we can connect at all; the returned connection serves system tablesfunction TDM.ConnectToDatabase(var SQLConnection : TSQLConnection; const test : boolean = false) : boolean;var  connName : string;  i : integer;begin  Result := false;  if test then    begin      connName := gConf.ReadString(secConn, 'connectionType', connList[0]);      if gConf.ReadError then exit; // connection type does not exists      FconnType := -1;      for i := 0 to High(connList) do        if connName = connList[i] then          FconnType := i;      if FconnType = -1 then exit; // no match      SQLconnection := connSQL;      SQLTranUpdate.DataBase := SQLConnection;    end;  SQLDBLibraryLoader.ConnectionType := connList[FconnType];  case FconnType of    0 : begin         // SQLite3          SQLiteLibraryName := gConf.ReadString(secConn, 'libraryName', SQLiteLibraryName);          SQLConnection := TSQLite3Connection.Create(self);        end;    1 : begin         //MySQL4.0          SQLConnection := TMySQL40Connection.Create(self);          TMySQL40Connection(SQLConnection).Port := gConf.ReadInteger(secConn, 'port');        end;    2 : begin         //MySQL5.5          SQLConnection := TMySQL55Connection.Create(self);          TMySQL55Connection(SQLConnection).Port := gConf.ReadInteger(secConn, 'port');        end;    3 : begin         //MySQL5.7          SQLConnection := TMySQL57Connection.Create(self);          TMySQL57Connection(SQLConnection).Port := gConf.ReadInteger(secConn, 'port');          TMySQL57Connection(SQLConnection).SkipLibraryVersionCheck:= true;        {$IFDEF UNIX}          SQLDBLibraryLoader.LibraryName := gConf.ReadString(secConn, 'libraryName', 'libmysqlclient.so');        {$ENDIF}        end;    4 : begin         //MSSQL          SQLConnection := TMSSQLConnection.Create(self);        end;    end;  SQLConnection.DatabaseName := gConf.ReadString(secConn, 'databaseName');  SQLConnection.HostName := gConf.ReadString(secConn, 'hostName');  SQLConnection.UserName := gConf.ReadString(secConn, 'userName');  SQLConnection.Password := gConf.ReadString(secConn, 'password');  SQLConnection.LoginPrompt := gConf.ReadBoolean(secConn, 'loginPrompt');  if test then    begin      SQLDBLibraryLoader.Enabled := true;      SQLDBLibraryLoader.LoadLibrary;    end;  SQLConnection.Open;  Result := SQLConnection.Connected;  if test then SQLConnection.Close;end;  gConf is an XML configuration file, it works exactly same way as TINIFile. For example: 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   SQLConnection.HostName := gConf.ReadString(secConn, 'hostName');reads HostName key from section which name is in secConn constant. Third parameter is the default value, it is not present here, so it would return empty string, if there were no such key. You can throw away all that complexity, I did not do it just to avoid deleting something important. The above code was tested and worked with SQLite 3  on Windows and Linux; mySQL 5.6 and 5.7 on Linux; MSSQL (SQLServer 2012) on Windows. The chain is TSQLConnection -> TSQLTransaction -> TSQLQuery -> [TDataSource] Other components are not dependent on connection type, they usually reside on forms, where needed, along with DBGrids and other data-aware components. ---------------------------------------------------------------------- Thaddy · 2016-12-05 07:39 If you have Laz 1.6 or 1.7 AND very important FPC 3.0 or higher the component is also installed. So 5.7 was already in 3.0.x. Ergo : Your Lazarus may be up to date but you are using an old and unsupported version of FPC (maybe 2.6.4?) FPC 3.0 is the current release version. ---------------------------------------------------------------------- vrull · 2016-12-06 04:24 In Lazarus 1.6 the unit mysql57conn is installed, but the component does not exist in the component palette. Not sure how it is in 1.7.