Java MySQL error access denied for user [. ] when connecting to a non-local database?

ya
- in Servers
8

After a long programming break, I once again sat down to a project. For this I need the MySQL class. Because the project is not just local

for me on the PC, but also on other PCs should be used, came for me a local database out of the question. Now I've bought a cheap Minecraft server at a Minecraft hoster, because it includes a database and I know of no hosters who rent only a pure database.

Now I have, as usual before my break, first written an SQL connection class. When an "Access denied" error message came on the first try, which I never had before with the method, I first thought that I had entered data incorrectly. After several checks I'm still desperate before this error message. After a long Google, I came now also no solution to my problem.

I use windows. Maybe a MySQL veteran can help me out.

Ar

MySQL usually prohibits access from outside. This must first be explicitly enabled on the MySQL service. A hoster who opens his MySQL services to the outside would not be trusted because he makes all databases on his system vulnerable.

ya

Say, I would have to grow my own server, then I would have to install MySQL, so that is possible?

Ar

Theoretically yes. But this will make you your own server vulnerable.

Why do you want to use your one remote database? If necessary. Would it be more useful to use an API that you can address remotely and then you store the transferred data in the database. But just depends on what you actually want to implement.

Bu

(…) and I do not know hosters who only rent a pure database.

And searched (online database hosting) you do not seem to have?

But from that: What speaks against not getting a normal webspace right away? So much additional costs should not arise there. And instead of accessing the database directly, you could put an application in front of it (an API service) that logically limits access to the database.

(…) an "Access denied" error message (…)

The error message is unique. If the authentication data is correct, there might be something else that blocks direct access to the database. Ask the hoster.

ya

I have to say that it has always worked out that I could connect directly to the database and then easily write or read data. I have not worked with APIs yet and I do not understand exactly how that should work. So, as far as I can understand, I can't directly address the server, but must first build an API, which I then address and then transmits the data for me. How do I connect the API to MySQL, how exactly do I build the API?

ya

Is there no way, I do not have logically access to the MySQL server, since I've rented only one database. Is there a possibility that I can activate the direct communication by a setting of only my database, since I have access through phpmyadmin or is that only regulated by the server? For my project actually the direct variant should suffice.

Ar

No, there's no other way.

Bu

The simplest case of such an API could be a web application that simply calls a different code block per URL, which returns a different result.

Example with pseudocode:

string action = getRequestUrl (). GetQuerystringParameters () ["action"];

switch (action):
case "sayHello":
print ( "Hello")
return
case "sayGoodbye":
print ( "Goodbye")
return
default:
print ( "")

The URL:

http://www.your-domain.de?action=sayHello

So get a response with "Hello" back. Of course, for your application, you would implement functions that provide data from the database (such as: returning all usernames from table X, or similar).

You can freely decide how you design the URL (whether you use querystring parameters as above or your own controller actions / pages), which functions you provide and which format you use (JSON, XML, text only as above, …).

It would be advisable to save the API at this point. Look at OAuth2 or use something like an HMAC authenfication. The requesting application must first authenticate itself before it can request and receive responses.

The language in which you can develop the API depends on the web host (or its server configuration).

What do I do now? Or Orangetidy
MySQL Access denied? Br Bright507