newbie: mysql_connect problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yoyoz
    New Member
    • Apr 2007
    • 7

    #1

    newbie: mysql_connect problem

    Help!!!! i am newbie to php, i was trying to establish the connection to another machine (solaris) so that i can retrieve data from the database stored inside there using my own PC.

    for your information, i am using apache 1.3.27 as my web server, php4 and mysql as i try to build an database with a web portal.

    the following is the scripts that i have written:

    [PHP]
    <?php
    $connection = mysql_connect ("202.185.72.62 :80","root","" ) or die ("connection failed");
    echo ("connection made!");
    mysql_close($co nnection);
    ?>
    [/PHP]

    i have also try to use default port number to connect (3306) but it still cannot work!

    below is the error message that i got:

    Warning: Lost connection to MySQL server during query in c:\phpdev\www\t ry_connection.p hp on line 2

    Warning: MySQL Connection Failed: Lost connection to MySQL server during query in c:\phpdev\www\t ry_connection.p hp on line 2

    Fatal error: Maximum execution time of 30 seconds exceeded in c:\phpdev\www\t ry_connection.p hp on line 2
    please help me as i am totally run out of idea! thanks..
  • cyberking
    New Member
    • Jan 2007
    • 84

    #2
    Hi
    I am not very sure, I too had the same problems a while ago. Anyways, try increaing the time out value in your php.ini file to a very large value. Increase it to say 10000 seconds.. Also use the port number 3306. Check your firewall settings. Open a port for MySql if there s not one already. Or best, time being disable firewall just to ensure its not your firewall thats not lettin u to connect.
    Regards

    Originally posted by yoyoz
    Help!!!! i am newbie to php, i was trying to establish the connection to another machine (solaris) so that i can retrieve data from the database stored inside there using my own PC.

    for your information, i am using apache 1.3.27 as my web server, php4 and mysql as i try to build an database with a web portal.

    the following is the scripts that i have written:

    [PHP]
    <?php
    $connection = mysql_connect ("202.185.72.62 :80","root","" ) or die ("connection failed");
    echo ("connection made!");
    mysql_close($co nnection);
    ?>
    [/PHP]

    i have also try to use default port number to connect (3306) but it still cannot work!

    below is the error message that i got:



    please help me as i am totally run out of idea! thanks..

    Comment

    • yoyoz
      New Member
      • Apr 2007
      • 7

      #3
      Originally posted by cyberking
      Hi
      I am not very sure, I too had the same problems a while ago. Anyways, try increaing the time out value in your php.ini file to a very large value. Increase it to say 10000 seconds.. Also use the port number 3306. Check your firewall settings. Open a port for MySql if there s not one already. Or best, time being disable firewall just to ensure its not your firewall thats not lettin u to connect.
      Regards
      I am not sure what you mean by open a port for MySQL, can you describe it in more details. As you were mentioned, you were having the same problem, what is the solution for you at last? I have disable the firewall in my PC, maybe i will try to change the time out value, but shouldn't it be connected very fast if there is no connection problem? thanks for your reply..

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Hi.

        Are you sure your MySQL is set to accept remote connection?

        Btw. it would be much easyer to diagnose the problem if you'd print the error message when your connection fails.

        You can do that like this
        [PHP]
        mysql_connect($ q, $l) or die(mysql_error ());
        [/PHP]

        Comment

        • yoyoz
          New Member
          • Apr 2007
          • 7

          #5
          Originally posted by Atli
          Hi.

          Are you sure your MySQL is set to accept remote connection?

          Btw. it would be much easyer to diagnose the problem if you'd print the error message when your connection fails.

          You can do that like this
          [PHP]
          mysql_connect($ q, $l) or die(mysql_error ());
          [/PHP]
          Hi,
          how to set MySQL to the accept remote connection? Below is the MySQL environment setting in the DB server, in this case the Solaris machine that i've mentioned earlier in the post. Is the setting correct?

          MySQL Support enabled
          Active Persistent Links 0
          Active Links 0
          Client API version 4.0.26
          MYSQL_MODULE_TY PE external
          MYSQL_SOCKET /tmp/mysql.sock
          MYSQL_INCLUDE -I/usr/local/mysql/include
          MYSQL_LIBS -L/usr/local/mysql/lib -lmysqlclient

          Directive Local Value Master Value
          mysql.allow_per sistent On On
          mysql.connect_t imeout 60 60
          mysql.default_h ost no value no value
          mysql.default_p assword no value no value
          mysql.default_p ort no value no value
          mysql.default_s ocket no value no value
          mysql.default_u ser no value no value
          mysql.max_links Unlimited Unlimited
          mysql.max_persi stent Unlimited Unlimited
          mysql.trace_mod e Off Off
          And below is the error message that i got when i am trying to the DB server from my own PC.
          Warning: mysql_connect() : Can't connect to MySQL server on '202.185.72.62' (10054) in c:\program files\easyphp1-7\www\try_solar is.php on line 2
          Can't connect to MySQL server on '202.185.72.62' (10054)
          Thanks...

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            I'm not sure how this would work on Solaris machines, but I do know that mysql will not allow remote access to the root account by default, have you tried creating another account?
            By crateing a user without specifying an IP address MySQL should accept remote connections on that user from anybody.

            Comment

            Working...