Recent

Author Topic: MySQL connect failed  (Read 5438 times)

ironman139

  • New Member
  • *
  • Posts: 36
MySQL connect failed
« on: October 21, 2016, 04:28:50 am »
Hello,

I try since 3 days to set up my Lazarus SQL programm.
I have a local Mamp server running. I can connect from every computer to the server, and PHPMyAdmin.
But when i try to connect to the SQL database with my Lazarus programm its not possibel, (-> picture)
I created a short php script and this one connects to my sql database without any problems.
(->picture)

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, mysql56conn, sqldb, FileUtil, Forms, Controls, Graphics,
  9.   Dialogs, StdCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Edit1: TEdit;
  18.     Edit2: TEdit;
  19.     Edit3: TEdit;
  20.     Memo1: TMemo;
  21.     MySQLConnection1: TMySQL56Connection;
  22.     SQLConnector1: TSQLConnector;
  23.     SQLQuery1: TSQLQuery;
  24.     SQLTransaction1: TSQLTransaction;
  25.     procedure Button1Click(Sender: TObject);
  26.   private
  27.     { private declarations }
  28.   public
  29.     { public declarations }
  30.   end;
  31.  
  32. var
  33.   Form1: TForm1;
  34.  
  35. implementation
  36.  
  37. {$R *.lfm}
  38.  
  39. { TForm1 }
  40.  
  41. procedure TForm1.Button1Click(Sender: TObject);
  42. begin
  43.   // Set the connection parameters.
  44.     MySQLConnection1.HostName := '192.168.1.119:8889';
  45.     MySQLConnection1.UserName := 'root';
  46.     MySQLConnection1.Password := 'root';
  47.     MySQLConnection1.DatabaseName := 'implantec'; // MySQL is allways there!
  48.     //ShowMessage('Opening a connection to server: ' + 'SQL');
  49.     MySQLConnection1.Open;
  50.  end;
  51.  
  52.  
  53. end.
  54.  


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: MySQL connect failed
« Reply #1 on: October 21, 2016, 07:45:16 am »
Is port really allowed to be part of hostname that way I wonder. (and I replied that on SO yesterday too).

Did you really research this item in the wiki as I advised?

Omirbay

  • New Member
  • *
  • Posts: 12
Re: MySQL connect failed
« Reply #2 on: October 21, 2016, 09:47:04 am »
Hello!

Recently, I was creating app that works with Mysql database. I think you also need to copy proper libmysql.dll connector library to your system directory (c:\windows\system32) / app exe directory. Also. For your information whether you noticed or not, in object inspector of mysql56 component there is a field dedicated for port if not mistaken. Try these out, if does not help, wud be happy to help. Since my program is running without problems now.

With respect,
Omirbay

ironman139

  • New Member
  • *
  • Posts: 36
Re: MySQL connect failed
« Reply #3 on: October 21, 2016, 04:49:14 pm »
I have the .dll in my project dir and in system32.
I removed the port from the Hostname and added it in the settings directly.
Unfortunately no change ...

Regards Tim

Omirbay

  • New Member
  • *
  • Posts: 12
Re: MySQL connect failed
« Reply #4 on: October 26, 2016, 02:24:56 pm »
Hi there!

Bear in mind that
 Libmysql.dll n ur windows os version shud be identical as well as ur lazarus mysql connection component.

Luk forward to hearing from u soon about ur achievements.

Wiz respect
Omirbay

ironman139

  • New Member
  • *
  • Posts: 36
Re: MySQL connect failed
« Reply #5 on: October 27, 2016, 03:57:46 am »
I figured it out. It was a problem between different version´s of the MySQL

 

TinyPortal © 2005-2018