Lazarus

Free Pascal => Database => Topic started by: HappyLarry on October 19, 2016, 02:19:51 pm

Title: Connecting to MariaDB on XAMPP
Post by: HappyLarry on October 19, 2016, 02:19:51 pm
I have XAMPP running on Linux. XAMPP is installed (automatically)  at /opt/lampp/. I have libmysqlclient18 5.6.3 installed.  XAMPP has MariaDB as part of it but Iunderstand that is fully compatible with sqldb and mysql.

I also have a database called DB on it. The database user name is 'root' and it has no password as is standard for XAMPP. The database functions correctly and I can see the database through localhost/phpmyadmin. I am trying to connect Lazarus to it.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   MySQL56Connection1.Hostname := 'localhost';
  4.   MySQL56Connection1.DatabaseName:='DB';
  5.   MySQL56Connection1.UserName:='root';
  6.   MySQL56Connection1.Transaction:=SQLTransaction1;
  7.   SQLTransaction1.Database:=MySQL56Connection1;
  8.  
  9.   SQLQuery1.Database:=MySQL56Connection1;
  10.   SQLQuery1.Transaction:=SQLTransaction1;
  11.   SQLQuery1.SQL.Text:='SELECT * FROM MyTable';
  12.  
  13.   Datasource1.dataset:=SQLQuery1;
  14.   DBGrid1.DataSource:=DataSource1;
  15.  
  16.   MySQL56Connection1.Open;
  17.   If MySQL56Connection1.Connected then
  18.   begin
  19.        Label1.caption:='connected';
  20.   end;
  21. end;
  22.  

I get an error Server connect failed'. Can anyone see what I am doing wrong? I suspect it is the database name but I don't know what I should put instead.
Title: Re: Connecting to MariaDB on XAMPP
Post by: HappyLarry on October 19, 2016, 04:56:21 pm
A bit more information:
In XAMPP,  mysql is found at
/opt/lampp/bin
and I have changed my .bashrc file with
PATH=${PATH}:/opt/lampp/bindb
so that if I type
mysql -u root
anywhere then mysql (MariaDB) opens successfully. Unfortunately when Lazarus tries to connect, I still get the same error.
Title: Re: Connecting to MariaDB on XAMPP
Post by: rsouza on April 27, 2017, 03:40:04 pm
You also need to put the libs folder in your .bashrc.
TinyPortal © 2005-2018