Recent

Author Topic: [HELP] Connecting to a SQL - Console Application  (Read 28455 times)

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114

rvk

  • Hero Member
  • *****
  • Posts: 4324
Re: [HELP] Connecting to a SQL - Console Application
« Reply #16 on: December 17, 2014, 08:34:04 pm »
Then the libmysql.dll is not the correct one (or corrupt).
Where did you get it?

And i stand corrected about the version.
According to this it should be 5.1
http://www.000webhost.com/free-mysql-hosting

So you should use "MySQL 5.1" as ConnectionType and mysql51conn in the uses-clause. (and the correct libmysql.dll)
« Last Edit: December 17, 2014, 08:38:36 pm by rvk »

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #17 on: December 17, 2014, 08:41:43 pm »
I downloaded it off a random DLL website. I now get this error:

http://screenshu.com/static/uploads/temporary/dx/w4/6f/f2x9qy.jpg

If you can see that. I put the DLL file into system32 and my folder.

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #18 on: December 17, 2014, 08:44:05 pm »
Then the libmysql.dll is not the correct one (or corrupt).
Where did you get it?

And i stand corrected about the version.
According to this it should be 5.1
http://www.000webhost.com/free-mysql-hosting

So you should use "MySQL 5.1" as ConnectionType and mysql51conn in the uses-clause. (and the correct libmysql.dll)

Also when I put SQL 5.1 is then doesn't work. Its 4.1 thats fine. I still can't get it to get passed the breaking at Aconnetion.open. When I install the funny dll file it doesn't give me that error but just self closes however when I change it to 5.1 it then re gives me the error.

rvk

  • Hero Member
  • *****
  • Posts: 4324
Re: [HELP] Connecting to a SQL - Console Application
« Reply #19 on: December 17, 2014, 09:01:01 pm »
There might also be another problem going on...
I'm trying to get it to work on my end but are also getting errors.

Are you sure you have remote access to that host and database??

Normally internet providers block direct access to MySQL and only allow their own machines access.
See also http://serverfault.com/a/481616/189940

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #20 on: December 17, 2014, 09:10:24 pm »
So you think its there database? So if I change the databases the program will work?

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #21 on: December 17, 2014, 09:13:13 pm »
There might also be another problem going on...
I'm trying to get it to work on my end but are also getting errors.

Are you sure you have remote access to that host and database??

Normally internet providers block direct access to MySQL and only allow their own machines access.
See also http://serverfault.com/a/481616/189940

Could you please try a random server and see if thats the issue? That "http://www.freesqldatabase.com/" website doesn't work

rvk

  • Hero Member
  • *****
  • Posts: 4324
Re: [HELP] Connecting to a SQL - Console Application
« Reply #22 on: December 17, 2014, 09:18:05 pm »
Well, I'm getting this error if I try to connect using MySQL Workbench.
http://www.mysql.com/products/workbench/
You can download it yourself (you can skip the registration).

In your setup of the database at 000webhost, do you have options to allow certain IP-addresses ??
« Last Edit: December 17, 2014, 09:19:37 pm by rvk »

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #23 on: December 17, 2014, 09:22:01 pm »
No. Ill look to how I would make it public now. However will it work on an open server?

rvk

  • Hero Member
  • *****
  • Posts: 4324
Re: [HELP] Connecting to a SQL - Console Application
« Reply #24 on: December 17, 2014, 10:53:08 pm »
I know from my own MySQL server (on an internal Linux-box) that you need to add 'username'@'hostname' to the user table to allow a connection from hostname. You could use % as hostname but that opens up a whole lot of security issues.

I can connect to my own box with MySQL Workbench and finally was able to connect from Lazarus remotely to that box. The error-messages Lazarus produces are very unclear. I always got a "Server connect failed" until I opened up the connection to a wildcard-host (the % I mentioned above). I should have gotten the same clear message Workbench gave me. But it works. Changing the % (wildcard) to my hostname (from where I connected) works too.

So... some notes.
  • You need to add the username@host to your users table in mysql (I'm not sure if this is possible at 000webhost) or otherwise the provider should have provided a webinterface to set "allowed hosts" (which very few do because of security issues).
  • You need the right libmysql.dll (in combination with the client installed.) You probably can connect with 5.1 to a 5.5 server but if you have a 5.1 library you should use mysql51conn and "MySQL 5.1" (or go with TMySQL51Connection). The last example we used was okay.

So, I think the first thing you need to do is check if you can set an allowed host for that mysql database. If not you're out of luck (at that provider) and you can only access the mysql from the webpages hosted at that same provider. If that's the case you could also look for a provider where you can set access from outside.

rvk

  • Hero Member
  • *****
  • Posts: 4324
Re: [HELP] Connecting to a SQL - Console Application
« Reply #25 on: December 17, 2014, 10:55:32 pm »
And here is your answer:
http://www.000webhost.com/faq.php?ID=27

Quote
How can I connect to MySQL from my computer?
Remote MySQL connections are disabled for security and server performance reasons.

However remote MySQL connections will be enabled if you upgrade your account at http://www.000webhost.com/upgrade

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #26 on: December 17, 2014, 11:03:45 pm »
A few questions.
1) When I compile the exe and send it to a friend they wont need the dll file will they?
2) What hosting are you using for the SQL? I want touse the same as it sounds easier
3) I have no idea how to add username@myhost and stuff

Sorry.

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #27 on: December 17, 2014, 11:05:31 pm »
So all in all I need to get the username@domain and the dll file and it should work?

rvk

  • Hero Member
  • *****
  • Posts: 4324
Re: [HELP] Connecting to a SQL - Console Application
« Reply #28 on: December 17, 2014, 11:28:56 pm »
So all in all I need to get the username@domain and the dll file and it should work?
You would need to add 'a3762836'@'you_own_hostname' to the user table in the mysql installation and grant the necessary access. You can do that with your own installation of MySQL but you can't do this at a MySQL-provider. They just don't allow that. And 000webhost completely disables remote access for their free accounts.

A few questions.
1) When I compile the exe and send it to a friend they wont need the dll file will they?
2) What hosting are you using for the SQL? I want touse the same as it sounds easier
3) I have no idea how to add username@myhost and stuff

Sorry.
  • Yes, he does need the libmysql.dll too. So you need to send both files.
  • I don't have any open MySQL-connections to the internet. I have my own server for my internal network. My internal webpages (which a can host to the internet if i wanted to) access the locally installed MySQL-installation. My professional website is hosted by an internet provider. The MySQL-access there is also blocked and only accessible from their server (i.e. my professional website)
  • You can only add the user@host with your own MySQL-installation. Others will never let you have access to it because it would be a security breach.
(no need to be sorry, i'm happy to explain it)

So... you have 4 options:
  • Depending on what the program needs to do... you could create this in PHP (instead of Lazarus) and let the users go to your webpages at 000webhost where they interact with those pages.
  • You can install your own MySQL-server and allow port 3306 for MySQL through your router to your PC. Your PC would need to be on for others to access your MySQL-server. You could use Xamp or Wamp for a complete and easy to install solution for a web and MySQL-installation
  • Like option 1... you could create webpages (instead of a Pascal-program) and host them yourself on your own computer. For this options your computer also needs to be on when they want to access the pages and you can use the same Xamp or Wamp installation as option 2. In this case you wouldn't forward port 3306 but port 80 to your own computer.
  • You can look for another MySQL-provider which allows external access. There are a few but I'm not sure what their quality is.

O... yeah... option 5.... pay for access to a MySQL-server  :) In that case they usually have an option for remote access. But always check beforehand. And if your program runs at multiple locations you need to make sure you have access from all those (or all) locations.

Your choice would all depend on what kind of program it is and who uses it.
« Last Edit: December 17, 2014, 11:34:06 pm by rvk »

nobodyknowsme

  • Full Member
  • ***
  • Posts: 114
Re: [HELP] Connecting to a SQL - Console Application
« Reply #29 on: December 17, 2014, 11:47:02 pm »
Thank you. It's a Lazuras game. They use there login from the website on there console appication. It needs to be a console application. I will have to buy a SQL database that allows outside access to everyone as the program will be available to everyone. It will have to be option 4.
« Last Edit: December 17, 2014, 11:49:44 pm by nobodyknowsme »

 

TinyPortal © 2005-2018