Recent

Author Topic: Lazarus and Mysql on remote computer does not work  (Read 937 times)

alander

  • Newbie
  • Posts: 3
Lazarus and Mysql on remote computer does not work
« on: March 23, 2021, 04:56:39 pm »
Hi, please
I am using Lazarus the last version with mysql 8.0. The local connection everything goes well, but on remote machine, my app cannot connect to
database on server. Could you help me please ?

I am using windows 10 64bits
I have opened the port 3306 in Server computer firewall but it does not work.
In mysql I have created a user with all privilegies for local and all network connection. I have tried with root user as well, but I cannot.

this is my .ini file from my application
In my application folder, I use my app file, .ini., libmysql.dll, zlib1.dll and nothing else

IP=Server
Database=soft
Port=3306
Library=C:\soft\libmysql.dll
User=soft
Pass=*********


When I tried to open my app on remote computer the message error is:

Client-Library c:\myapp\libmysql.dll found but could not be loaded. Check compile-target and library compatibility!.

What do I have to do ? I am new with lazarus, I came from Delphi.

Regards
« Last Edit: March 23, 2021, 04:58:13 pm by alander »

BSaidus

  • Sr. Member
  • ****
  • Posts: 374
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: Lazarus and Mysql on remote computer does not work
« Reply #1 on: March 23, 2021, 06:24:35 pm »
May be you miss to create a user like this on myssql:
     user@%
and give this user the rights on the desired database
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

af0815

  • Hero Member
  • *****
  • Posts: 674
Re: Lazarus and Mysql on remote computer does not work
« Reply #2 on: March 23, 2021, 10:35:57 pm »
Client-Library c:\myapp\libmysql.dll found but could not be loaded. Check compile-target and library compatibility!.
In Lazarus you are able to compile for 32Bit or 64Bit. So depending on this you have to use the correct dll's for the bitness. A 32bit programm can not use a 64Bit library and 64Bit programm can not work with a 32 bit dll.

with pesp https://github.com/stievie/pesp you can check the bitness - the programm must be compiled with lazarus/fpc.
regards
Andreas

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 512
  • Professional amateur ;-P
Re: Lazarus and Mysql on remote computer does not work
« Reply #3 on: March 23, 2021, 11:33:49 pm »
Hi Alander,

Let's give you a checklist for you to go through and see what's what:
  • Can you connect to the remote server by using a tool like HeidiSQL or the MySQL Workbench
    This will make sure that firewall rules are good and you created the correct user format.
  • Like @BSaidus mentioned, is your user created like: user@% or user@localhost?
    For remote usage you need the user@% version
  • Make sure that you have/include the correct *.dll files for the architecture of your binary.
    That means if you compile your app as 64b, it will only dynamically load 64b *.dll, never 32b *.dll.
    If you compile your app as 32b, it will only dynamically load 32b *.dll, never 64b *.dll.
  • The *.dll have to be, either on the same folder of the binary or in the path of the system.
  • The BindAddress-Parameter in my.ini/my.cnf <-- As suggested by @Zvoni
    Out-of-the Box MySQL listens only to localhost
  • I'm sure I'm missing some other steps, I'll ask the community to pad my holes, thanks!

When I say binary I mean the app's *.exe file. Sorry, more used to Linux lingo.

Cheers,
Gus
« Last Edit: March 25, 2021, 02:50:50 am by gcarreno »
Lazarus 2.1.0(trunk) FPC 3.3.1(trunk) Ubuntu 20.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.0(stable) Ubuntu 20.10 64b Dark Theme
http://github.com/gcarreno

Zvoni

  • Hero Member
  • *****
  • Posts: 550
Re: Lazarus and Mysql on remote computer does not work
« Reply #4 on: March 24, 2021, 08:04:52 am »
Gus, you forgot one stumbling stone of MySQL:
The BindAddress-Parameter in my.ini/my.cnf

Out-of-the Box MySQL listens only to localhost
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircraft

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 512
  • Professional amateur ;-P
Re: Lazarus and Mysql on remote computer does not work
« Reply #5 on: March 25, 2021, 02:48:14 am »
Hi Zvoni,
Gus, you forgot one stumbling stone of MySQL:
The BindAddress-Parameter in my.ini/my.cnf

Out-of-the Box MySQL listens only to localhost

ARGH, I knew I forgot something.
Erroneously, I think I assumed that if he fiddled with the Firewall he fiddle with my.cnf.
Sorry, my bad, will edit my post!!

Many thanks for the save Zvoni!!

Cheers,
Gus
« Last Edit: March 25, 2021, 02:50:01 am by gcarreno »
Lazarus 2.1.0(trunk) FPC 3.3.1(trunk) Ubuntu 20.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.0(stable) Ubuntu 20.10 64b Dark Theme
http://github.com/gcarreno

alander

  • Newbie
  • Posts: 3
Re: Lazarus and Mysql on remote computer does not work
« Reply #6 on: March 30, 2021, 12:28:25 pm »
Hi, please
I am using Lazarus the last version with mysql 8.0. The local connection everything goes well, but on remote machine, my app cannot connect to
database on server. Could you help me please ?

I am using windows 10 64bits
I have opened the port 3306 in Server computer firewall but it does not work.
In mysql I have created a user with all privilegies for local and all network connection. I have tried with root user as well, but I cannot.

this is my .ini file from my application
In my application folder, I use my app file, .ini., libmysql.dll, zlib1.dll and nothing else

IP=Server
Database=soft
Port=3306
Library=C:\soft\libmysql.dll
User=soft
Pass=*********
Client-Library c:\myapp\libmysql.dll found but could not be loaded. Check compile-target and library compatibility!.
In Lazarus you are able to compile for 32Bit or 64Bit. So depending on this you have to use the correct dll's for the bitness. A 32bit programm can not use a 64Bit library and 64Bit programm can not work with a 32 bit dll.

with pesp https://github.com/stievie/pesp you can check the bitness - the programm must be compiled with lazarus/fpc.
Client-Library c:\myapp\libmysql.dll found but could not be loaded. Check compile-target and library compatibility!.
In Lazarus you are able to compile for 32Bit or 64Bit. So depending on this you have to use the correct dll's for the bitness. A 32bit programm can not use a 64Bit library and 64Bit programm can not work with a 32 bit dll.

with pesp https://github.com/stievie/pesp you can check the bitness - the programm must be compiled with lazarus/fpc.


When I tried to open my app on remote computer the message error is:

Client-Library c:\myapp\libmysql.dll found but could not be loaded. Check compile-target and library compatibility!.

What do I have to do ? I am new with lazarus, I came from Delphi.

Regards

Hi, thanks for your contact.
I am using now 64 bits from my aplication and mysql dll. but When I try to connect from a remote pc, I recive a message error Access denied for user .....
I have created a new user with all permisses in mysql in graphics mode, but I do not know what is the problem.

dseligo

  • Full Member
  • ***
  • Posts: 247
Re: Lazarus and Mysql on remote computer does not work
« Reply #7 on: March 30, 2021, 12:44:16 pm »
You must specify in MySQL where from the user is allowed to connect.
I attached screenshot which shows how this is done in HeidiSQL. I marked setting which allow you to connect from anywhere.
« Last Edit: March 30, 2021, 12:46:32 pm by dseligo »

alander

  • Newbie
  • Posts: 3
Re: Lazarus and Mysql on remote computer does not work
« Reply #8 on: March 31, 2021, 12:19:35 pm »
You must specify in MySQL where from the user is allowed to connect.
I attached screenshot which shows how this is done in HeidiSQL. I marked setting which allow you to connect from anywhere.

Hi dseligo,

in my WorkBench I have put inside host % for all hosts and it does not work.
is there any mysql file to setup ?

thanks

Zvoni

  • Hero Member
  • *****
  • Posts: 550
Re: Lazarus and Mysql on remote computer does not work
« Reply #9 on: March 31, 2021, 01:45:40 pm »
What about BindAddress in my.cnf/my.ini?
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircraft

dseligo

  • Full Member
  • ***
  • Posts: 247
Re: Lazarus and Mysql on remote computer does not work
« Reply #10 on: April 01, 2021, 12:01:07 am »
I recive a message error Access denied for user .....
Can you give exact error message, word by word?
If you get this message, I'd say you are communicating with mySQL server.
Are you sure you are using correct password?

dseligo

  • Full Member
  • ***
  • Posts: 247
Re: Lazarus and Mysql on remote computer does not work
« Reply #11 on: April 01, 2021, 12:09:16 am »
And try SHOW GRANTS; on your database server (you can paste it here, blank password if it shows).
Did you restart mysql server after change?

 

TinyPortal © 2005-2018