Trouble connecting to MySQL from remote host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paradiselost
    Member
    • Apr 2004
    • 31

    #1

    Trouble connecting to MySQL from remote host

    I'm having trouble connecting to MySQL from a remote host using PHP. I have no problems connecting to the database from 'localhost', but when I change the host to mydomain.com and try to access it from a remote computer I get this error:

    Warning: Can't connect to MySQL server on 'mydomain.com' (110) in /usr/local/apache/htdocs/pathtoscript.php on line 11

    Warning: MySQL Connection Failed: Can't connect to MySQL server on 'mydomain.com' (110) in /usr/local/apache/htdocs/pathtoscript.php on line 11
    I cannot connect to the database because: Can't connect to MySQL server on 'mydomain.com' (110)

    I'm trying to connect using this script:

    PHP Code:
    $dbh=mysql_connect ("mydomain.com:3306""user""password") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db ("database"); 
    My access hosts in cPanel are % and localhost (this is the part I'm unsure of). I also added my remote IP address but got the same error message.

    Anyone have any ideas or gone through the same thing?
    --
    ** DEVTRENCH **
    --
    James Ehly
  • Jonathan
    Senior Member
    • Mar 2004
    • 1229

    #2
    Not entirely sure if you can remote access the mySQL...
    "How can someone be so distracted yet so focused?"
    - C

    Comment

    • Andy
      Senior Member
      • Mar 2004
      • 257

      #3
      From my understanding, cpanel does not allow external connections to mysql directly. The work around was to go through SSH. I saw some info on it here before, but I do not know if its on the new forums yet.

      Try searching, or hopefully someone will have the info.
      Andy

      Comment

      • KyleC
        Senior Member
        • Mar 2004
        • 291

        #4
        you cannot connect remotely directly like that... their used to be a FAQ on how to connect through plink...but we lost it

        did anyone save it?
        -Kyle

        Comment

        • KyleC
          Senior Member
          • Mar 2004
          • 291

          #5
          Question: Is direct connection to Dathorn MySQL server possible, without need to use web style admin? Answer: Yes, but... For security reasons native remote direct connection to MySQL server is disabled. So, you cannot use MySQLFront or other similar MySQL admin application to connect directly. However, since there
          -Kyle

          Comment

          • paradiselost
            Member
            • Apr 2004
            • 31

            #6
            Thanks for everyone's help...

            Thanks for all the replies.

            From my understanding, cpanel does not allow external connections to mysql directly. The work around was to go through SSH.
            Andy, since my script is in a php page does this mean I'd use an ssh tunnel with my browser? Sorry, I'm new to ssh. I can ssh into the command line just fine though. (Thanks for the tutorial KyleC).

            Anyway, my workaround for this problem was to create a local server environment consisting of Apache/PHP/MySQL. I'll work locally and then upload to the server - all I really wanted was a development environment - using the database on Dathorn though. Just being lazy I guess. Thanks again for all the support, I love this community!
            --
            ** DEVTRENCH **
            --
            James Ehly

            Comment

            • Andy
              Senior Member
              • Mar 2004
              • 257

              #7
              I am not sure how it worked, but I remember ppl using it. I believe they had SSH connection from there PC to the server, to access the Databases.

              It was on the old forums. It you are still wanting to do that, you may have to google for it.
              Andy

              Comment

              Working...