views:

53

answers:

5

I have, let's say, a root website with mysql db on a remote server.

I want to connect to that particular database (to make queries), from many other little websites (with lower priviledges).

Can this be done?

Language: jsp, java, php

+2  A: 

Any particular problem? Just specify server address instead of 'localhost' in connection string.
You can also create dedicated user with minimal privileges for that.

Nikita Rybak
+2  A: 

Yes it can be done, MySQL allows connections from remote hosts (assuming MySQL is configured to allow network connections and assuming the remote hosts are granted). In case of problem, the section 5.4.7. Causes of Access-Denied Errors lists most common problems and solutions.

Pascal Thivent
A: 

In addition to the answers from Nikita Rybak andPascal Thivent, I'd like to note that most hosting providers don't allow queries from locations other than localhost.

I don't know how much access you have to the server configuration, but I would have saved myself a headache a while back when I first started experimenting with connections across domains/servers.

Jan Kuboschek
+2  A: 

The default configuration often contains a variable

 skip-networking

which you need to comment-out in order to have networking enabled.

Dirk Eddelbuettel
+1. Thanks for adding that!
Jan Kuboschek
A: 

If the MySQL server is under your control, it's not difficult; you can find the procedure here. If it's not, the only thing you can do is beg the admin to do it, otherwise it's impossible.

Amadan