Recent

Author Topic: Connecting to MariaDB on XAMPP  (Read 10254 times)

HappyLarry

  • Full Member
  • ***
  • Posts: 155
Connecting to MariaDB on XAMPP
« 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.
Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

HappyLarry

  • Full Member
  • ***
  • Posts: 155
Re: Connecting to MariaDB on XAMPP
« Reply #1 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.
Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

rsouza

  • Newbie
  • Posts: 1
Re: Connecting to MariaDB on XAMPP
« Reply #2 on: April 27, 2017, 03:40:04 pm »
You also need to put the libs folder in your .bashrc.

 

TinyPortal © 2005-2018