mysql: localhost

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rich

    #1

    mysql: localhost

    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.


  • Nathan Gardiner

    #2
    Re: mysql: localhost

    Rich wrote:[color=blue]
    > 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.[/color]

    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 remoteuser@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


    Comment

    • Tim Van Wassenhove

      #3
      Re: mysql: localhost

      In article <cahgd2$bqi$1@n ewsg3.svr.pol.c o.uk>, Rich wrote:[color=blue]
      > 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?[/color]

      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>

      Comment

      • Rich

        #4
        Re: mysql: localhost

        Cool. Thanks.

        "Rich" <webmasterREMOV ETHIS@apolloesu .co.uk> wrote in message
        news:cahgd2$bqi $1@newsg3.svr.p ol.co.uk...[color=blue]
        > Hi. Whenever I connect to a mysql database, I always connect to[/color]
        'localhost'.[color=blue]
        > 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.
        >
        >[/color]


        Comment

        • Gary L. Burnore

          #5
          Re: mysql: localhost

          On Sun, 13 Jun 2004 13:12:31 +0100, "Rich"
          <webmasterREMOV ETHIS@apolloesu .co.uk> wrote:
          [color=blue]
          >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?[/color]

          Replace localhost with the FQDN. Like yourserver.doma in.com

          Simple.

          Comment

          • Chung Leong

            #6
            Re: mysql: localhost

            "Rich" <webmasterREMOV ETHIS@apolloesu .co.uk> wrote in message
            news:cahgd2$bqi $1@newsg3.svr.p ol.co.uk...[color=blue]
            > Hi. Whenever I connect to a mysql database, I always connect to[/color]
            'localhost'.[color=blue]
            > 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?[/color]

            It's possible, but most likely the port used by MySQL is blocked by your
            ISP's firewall.


            Comment

            • Epsilon

              #7
              Re: mysql: localhost

              Tim Van Wassenhove <euki@pi.be> wrote in
              news:2j367aFsaa 3sU1@uni-berlin.de:
              [color=blue]
              > In article <cahgd2$bqi$1@n ewsg3.svr.pol.c o.uk>, Rich wrote:[color=green]
              >> 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?[/color]
              >
              > 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.
              >[/color]

              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.

              Comment

              Working...