• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 294
  • Last Modified:

Why Delphi FireDac FdConnection component fails to load a remote MySql database from my website?

I don't succeed  to connect mySql database from within my WebSite to  FDConnection component. Though I set all necessary fields given by the "info" button (in the  "Control Panel")  of my hosting server.  
it seems the hosting name given "mysql1051.servage.net" is not accepted by the component!
Please Help
0
bish wakim
Asked:
bish wakim
  • 6
  • 6
  • 2
2 Solutions
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
FireDac appears to be a library (or setup libraries) licensed by Embarcadero.

For you Delphi code to work in your hosting environment, your hosting company would have to license + install these libraries.

To run Delphi applications on a public server, most likely you'll have to provision a bare metal machine + build up a Delphi runtime environment.

Refer to licensing of the products you've already purchased (Delphi + FireDac + etc...) as your license may cover running both a development machine + production machine. You'll just have to refer to your licensing agreements + likely open support tickets with each layer of code you'll have to install to create a Delphi runtime environment.

Likely a very long road.
0
 
Sinisa VukCommented:
No, this is not so complicated... Delphi is powerful enough...Just to install few libs on client side as described in this article... some parameters like server address, username, password, ...
0
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
As Sinisa said, this is fairly simple... if you own the servage.net domain + have root access to this domain to install the requisite libraries.

If you don't, resolution will be difficult.
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
bish wakimAuthor Commented:
I could make the connection localy after I downloaded the requested file libmysql.dll.
Every thing in fine so far. However when I try to connect to my database from within my remote WebSite and filled all the necessary parameteres(hostname, username ...) a problem arises!
Please Help
0
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Correct.

Locally, you have all Delphi libraries available.

Remotely, these must be paid for + installed by whatever hosting company you use.

As I said above, if you own the servage.net domain + have root access to this domain to install the requisite libraries, then just purchase a new Delphi license + follow their installation procedure.

All Delphi support libraries (there appear to be many) must exist in your runtime environment, before your code will run.

Also any additional components you're using in addition to Delphi core must also be installed, like FireDac appears to be an additional component.

In simple terms, all the steps you followed to setup your local runtime environment (all software you purchased + installed), must also be purchased + installed in your remote (hosting) runtime environment.
1
 
bish wakimAuthor Commented:
Please I am trying to understand!
I am not intending to run Delphi inside the host server. All I need is to read MySql database through my DeskTop App.
I have Already mySql Database in my server and have a component called FDConnection capable to connect when it is filled with
field such as : database name, hostname username and password.   My Server gives me these details! but when filled the connection fails.

According to Sinisa it should be possible
"
No, this is not so complicated... Delphi is powerful enough...Just to install few libs on client side as described in this article... some parameters like server address, username, password, ..."
0
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
If you're trying to run code at both your local + a remote location, then you'd just setup tunneling for whatever's required.

And... I'm guessing this will work differently than you imagine.

Normally you'd use Delphi to create some sort of UI driven application.

This means the UI would normally be on a front facing site for public access.

If you're only using your Delphi code locally + using your database remotely, then you'd just setup your remove MySQL/MariaDB to provide an SSL connection for a specific host (your local IP) + user + pass.

Keep in mind ISPs can change your local IP at any time, so if you take this approach you'll have to setup a new GRANT on your remote database, each time your ISP changes your IP.

Maybe you can explain more about your App, specifically what part of your App is running locally + remotely.

Normally entire Apps (or Websites) run on a public facing site, because running part of an App locally means your App will be exposed to normal ISP connectivity glitches + local power outages.

Describe all components of your App + likely someone can assist you.
0
 
bish wakimAuthor Commented:
Thank you. I think you became  closer to get my need. I will add thinks so you can assist me  .
I will come back later. A lot of thanks
Bishara
0
 
bish wakimAuthor Commented:
Hello David
Here are enough details about my question:
1. My application is done with delphi. my students are supposed to have the exe file installed on there Pc.
2. The Application exposes a game. After playing, each student gets a certain score this score is saved in a remote database.  
3.  This remote  database contains information about each player such as  name,age,score...should be simple table of mysql database and lives inside my website.
4. So, When students play the game each with his own desktop app,  their scores should be read and updated from and to mysql table.
5. I succeeded to  create this MySql table inside my hosting server(servage.net)
6. From Control panel of my hosting server  I got information see file "Capture"  attached file below!
7. from within my app i  droped  Fdcomponent and filled all nessary fields in it.see attached file capture2 !
8. When I test the connection. it fails!
9. A guy from india built this mysql table in his own website. and this works. I wish this mysql database to be in my own website.
10. I know it is possible beacause an indian guy did that for me but he created the database inside his own website.
Please have an idea?
Capture.PNG
Capture2.PNG
0
 
Sinisa VukCommented:
At first - your settings are correct and should be fine. Do you set you database to be access remotely when you create it? Do you sure that port 3306 if open behind router/pc firewall? Do you get any detailed description about an error when you hit test connection?

Additionally, you can try to use ADO components. Here is how to create Connection string:
Adoconnection1.ConnectionString := 'Driver={MySQL ODBC 5.1 Driver};Server=mysql1051.servage.net;Database=yourdb;User=yourdb;Password=xxxx;Option=3;'

Open in new window


if you send me privately message with test username/pw - maybe I can check it too...
0
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Got it.

Now I understand.

As Sinisa said, all should be well if...

1) There's no iptables block which disallows external connections to port 3306. Many ISPs + Distro firewalls block this by default.

2) Your MySQL/MariaDB instance is actually listening on port 3306. May ISPs block this by default.

3) You've created a valid GRANT from every PC to connect to your MySQL instance correctly.

This one can be tricky, because you'll either have to create a GRANT for each user or maybe a GRANT for a class C network.

4) Arrange for all the Delphi runtime libraries to be bundled into the App installed on each PC.

Just start through each of the items above + after you have #1-#2 working + one GRANT done (#3), then you should be able to open a test connection to your database instance.

To quickly test #1-#3, ssh into your hosting environment + setup a GRANT for a test user for IP 127.0.0.1 + port 3306 + test this first.

The setup another GRANT for the same test user for your own local IP + test again.

Doing a step-by-step progression through testing each connection will help you get everything working.
0
 
bish wakimAuthor Commented:
It is like magic! it seems that I forgot to set  database to be access remotely ... Every think is fine now. Thank you for you both. David and  Sinisa
You are wonderful!!!
0
 
bish wakimAuthor Commented:
Than you very much!!!
0
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
You're welcome.

Just be sure you wrap your database access in SSL, else anyone can see each user name/pass + can potentially hack your database.

If all your GRANT setups are setup on a per IP basis, this is less of an issue.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 6
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now