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
bish wakimAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Sinisa VukSoftware architectCommented:
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, ...
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.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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
David FavorLinux/LXD/WordPress/Hosting SavantCommented:

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.
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, ..."
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.
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
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?
Sinisa VukSoftware architectCommented:
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...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 + 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.
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!!!
bish wakimAuthor Commented:
Than you very much!!!
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.