By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

mysql: localhost

P: n/a
Hi. Whenever I connect to a mysql database, I always connect to 'localhost'.
Does that mean that you can connect to a database on another host? If you
can, does that mean that I could use the same database for both of my
websites (which are hosted with different people)? And if you can, how
please? I assume that I would have to create another mysql user, but how
would I connect to the database?

Thanks. Richard.
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Rich wrote:
Hi. Whenever I connect to a mysql database, I always connect to
'localhost'. Does that mean that you can connect to a database on
another host? If you can, does that mean that I could use the same
database for both of my websites (which are hosted with different
people)? And if you can, how please? I assume that I would have to
create another mysql user, but how would I connect to the database?

Thanks. Richard.


Richard,

You can, assuming the mysql database daemon is configured to allow remote
connections, and no firewall rules are preventing such a thing.

You will need to grant access to the databases for this host, assuming this
isn't already available. For example:

grant all on mydatabase.* to re********@192.168.1.1 identified by
somepassword;

You can now specify the ip address of this database server as the host for
any database applications.
Nathan
Jul 17 '05 #2

P: n/a
In article <ca**********@newsg3.svr.pol.co.uk>, Rich wrote:
Hi. Whenever I connect to a mysql database, I always connect to 'localhost'.
Does that mean that you can connect to a database on another host? If you
can, does that mean that I could use the same database for both of my
websites (which are hosted with different people)? And if you can, how
please? I assume that I would have to create another mysql user, but how
would I connect to the database?


If MySQL server is configured to use TCP/IP sockets it is possible.
But be aware that everything will be sent as plain-text. Most of the
times this is not wanted. A workaround would be to create a tunnel over
SSL to the server, and then connect to localhost:port of tunnel.

--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #3

P: n/a
Cool. Thanks.

"Rich" <we*****************@apolloesu.co.uk> wrote in message
news:ca**********@newsg3.svr.pol.co.uk...
Hi. Whenever I connect to a mysql database, I always connect to 'localhost'. Does that mean that you can connect to a database on another host? If you
can, does that mean that I could use the same database for both of my
websites (which are hosted with different people)? And if you can, how
please? I assume that I would have to create another mysql user, but how
would I connect to the database?

Thanks. Richard.

Jul 17 '05 #4

P: n/a
On Sun, 13 Jun 2004 13:12:31 +0100, "Rich"
<we*****************@apolloesu.co.uk> wrote:
Hi. Whenever I connect to a mysql database, I always connect to 'localhost'.
Does that mean that you can connect to a database on another host? If you
can, does that mean that I could use the same database for both of my
websites (which are hosted with different people)? And if you can, how
please? I assume that I would have to create another mysql user, but how
would I connect to the database?


Replace localhost with the FQDN. Like yourserver.domain.com

Simple.
Jul 17 '05 #5

P: n/a
"Rich" <we*****************@apolloesu.co.uk> wrote in message
news:ca**********@newsg3.svr.pol.co.uk...
Hi. Whenever I connect to a mysql database, I always connect to 'localhost'. Does that mean that you can connect to a database on another host? If you
can, does that mean that I could use the same database for both of my
websites (which are hosted with different people)? And if you can, how
please? I assume that I would have to create another mysql user, but how
would I connect to the database?


It's possible, but most likely the port used by MySQL is blocked by your
ISP's firewall.
Jul 17 '05 #6

P: n/a
Tim Van Wassenhove <eu**@pi.be> wrote in
news:2j************@uni-berlin.de:
In article <ca**********@newsg3.svr.pol.co.uk>, Rich wrote:
Hi. Whenever I connect to a mysql database, I always connect to
'localhost'. Does that mean that you can connect to a database on
another host? If you can, does that mean that I could use the same
database for both of my websites (which are hosted with different
people)? And if you can, how please? I assume that I would have to
create another mysql user, but how would I connect to the database?


If MySQL server is configured to use TCP/IP sockets it is possible.
But be aware that everything will be sent as plain-text. Most of the
times this is not wanted. A workaround would be to create a tunnel
over SSL to the server, and then connect to localhost:port of tunnel.


It would probably be worth the effort to just move one of your sites and
put them both on the same server. Then you can easily use the same database
and bypass the possible pesky technical issues.
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.