mysql accessed remotely

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

    #1

    mysql accessed remotely

    I want to know how you can access a remote mySQL database from a php script.

    Also how can I connect to a remote mysql database from mysql administrator?
  • Chris Hope

    #2
    Re: mysql accessed remotely

    Kenneth wrote:
    [color=blue]
    > I want to know how you can access a remote mySQL database from a php
    > script.[/color]

    mysql_connect($ ipaddress, $username, $password);

    where $ipaddress is the IP address of the server you want to connect to.
    Note that you may not be able to connect to a remote mysql database if
    a) the firewall blocks the mysql port b) mysql is not configured to
    listen to a port or c) your login doesn't have privileges to connect
    remotely.
    [color=blue]
    > Also how can I connect to a remote mysql database from mysql
    > administrator?[/color]

    Find the configuration dialog and set the hostname to an IP address. See
    above notes about why you still may not be able to connect.

    --
    Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

    Comment

    • Kenneth

      #3
      Re: mysql accessed remotely

      Here is the message i get when i use

      mysql_connect($ ipaddress, $username, $password);


      error:

      Warning: mysql_connect() : Unknown MySQL Server Host 'db195.perfora. net'
      (1) in /oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php
      on line 9

      Fatal error: Unknown MySQL Server Host 'db195.perfora. net' (1) in
      /oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php on line 9






      Chris Hope wrote:[color=blue]
      > Kenneth wrote:
      >
      >[color=green]
      >>I want to know how you can access a remote mySQL database from a php
      >>script.[/color]
      >
      >
      > mysql_connect($ ipaddress, $username, $password);
      >
      > where $ipaddress is the IP address of the server you want to connect to.
      > Note that you may not be able to connect to a remote mysql database if
      > a) the firewall blocks the mysql port b) mysql is not configured to
      > listen to a port or c) your login doesn't have privileges to connect
      > remotely.
      >
      >[color=green]
      >>Also how can I connect to a remote mysql database from mysql
      >>administrator ?[/color]
      >
      >
      > Find the configuration dialog and set the hostname to an IP address. See
      > above notes about why you still may not be able to connect.
      >[/color]

      Comment

      • Gordon Burditt

        #4
        Re: mysql accessed remotely

        >mysql_connect( $ipaddress, $username, $password);[color=blue]
        >
        >
        >error:
        >
        >Warning: mysql_connect() : Unknown MySQL Server Host 'db195.perfora. net'
        >(1) in /oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php
        >on line 9
        >
        >Fatal error: Unknown MySQL Server Host 'db195.perfora. net' (1) in
        >/oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php on line 9[/color]

        db195.perfora.n et is not a valid hostname. Fix your hostname
        or fix your DNS.

        Gordon L. Burditt

        Comment

        • Kenneth

          #5
          Re: mysql accessed remotely

          Gordon, why is not a valid hostname. and also how do i get the ip for
          db195.perfora.n et?


          Gordon Burditt wrote:[color=blue][color=green]
          >>mysql_connect ($ipaddress, $username, $password);
          >>
          >>
          >>error:
          >>
          >>Warning: mysql_connect() : Unknown MySQL Server Host 'db195.perfora. net'
          >>(1) in /oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php
          >>on line 9
          >>
          >>Fatal error: Unknown MySQL Server Host 'db195.perfora. net' (1) in
          >>/oldhome/WWW/wingsofthedawn. org/htdocs/final/Connections/myDB.php on line 9[/color]
          >
          >
          > db195.perfora.n et is not a valid hostname. Fix your hostname
          > or fix your DNS.
          >
          > Gordon L. Burditt[/color]

          Comment

          • Chris Hope

            #6
            Re: mysql accessed remotely

            Kenneth wrote:
            [color=blue]
            > Gordon, why is not a valid hostname. and also how do i get the ip
            > for db195.perfora.n et?[/color]

            You run "nslookup db195.perfora.n et" to get the IP address. This tells
            you that there is no such hostname which is why Gordon would have said
            it's not valid.

            --
            Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

            Comment

            • Kenneth

              #7
              Re: mysql accessed remotely

              So what is the next step?


              Chris Hope wrote:[color=blue]
              > Kenneth wrote:
              >
              >[color=green]
              >>Gordon, why is not a valid hostname. and also how do i get the ip
              >>for db195.perfora.n et?[/color]
              >
              >
              > You run "nslookup db195.perfora.n et" to get the IP address. This tells
              > you that there is no such hostname which is why Gordon would have said
              > it's not valid.
              >[/color]

              Comment

              • Chris Hope

                #8
                Re: mysql accessed remotely

                Kenneth wrote:
                [color=blue][color=green][color=darkred]
                >>>Gordon, why is not a valid hostname. and also how do i get the ip
                >>>for db195.perfora.n et?[/color]
                >>
                >> You run "nslookup db195.perfora.n et" to get the IP address. This
                >> tells you that there is no such hostname which is why Gordon would
                >> have said it's not valid.[/color]
                >
                > So what is the next step?[/color]

                Use a valid hostname. Or find out the actual IP address of the server
                you are trying to connect to. It's better to use the IP address anyway
                to prevent any extra latency required in looking it up each time your
                script wants to connect to the server.

                --
                Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

                Comment

                • Kenneth

                  #9
                  Re: mysql accessed remotely

                  Chris you were right it was behind a firewall. So now I am running
                  script inside the server.

                  Thanks.


                  Chris Hope wrote:[color=blue]
                  > Kenneth wrote:
                  >
                  >[color=green][color=darkred]
                  >>>>Gordon, why is not a valid hostname. and also how do i get the ip
                  >>>>for db195.perfora.n et?
                  >>>
                  >>>You run "nslookup db195.perfora.n et" to get the IP address. This
                  >>>tells you that there is no such hostname which is why Gordon would
                  >>>have said it's not valid.[/color]
                  >>
                  >>So what is the next step?[/color]
                  >
                  >
                  > Use a valid hostname. Or find out the actual IP address of the server
                  > you are trying to connect to. It's better to use the IP address anyway
                  > to prevent any extra latency required in looking it up each time your
                  > script wants to connect to the server.
                  >[/color]

                  Comment

                  Working...