mysql_connect error Apache Web server to Windows hosted database

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

    mysql_connect error Apache Web server to Windows hosted database

    Hi All,

    I've got MySQL 5.0.21 running on Windows Server 2003, and php running
    on Apache on a Linux box (Fedora Core 4).

    Previously when the pages were running on an IIS server the connection
    was succesful, now I get:

    Can't connect to MySQL server on 'SERVER' (13)

    I'm connecting using:

    $db = mysql_connect(" SERVER", "USER", "PASSWORD")
    or die("Could not connect to database:
    ".mysql_error() );
    mysql_select_db ("DATABASE", $db)
    or die("Could not select database: ".mysql_error() );

    However from the linux box I can connect no problems using:
    mysql --host=SERVER -u USER -p

    Can anyone help point me in the right direction to solve this one?
    Cheers
    Dan

  • Jerry Stuckle

    #2
    Re: mysql_connect error Apache Web server to Windows hosted database

    GD wrote:
    Hi All,
    >
    I've got MySQL 5.0.21 running on Windows Server 2003, and php running
    on Apache on a Linux box (Fedora Core 4).
    >
    Previously when the pages were running on an IIS server the connection
    was succesful, now I get:
    >
    Can't connect to MySQL server on 'SERVER' (13)
    >
    I'm connecting using:
    >
    $db = mysql_connect(" SERVER", "USER", "PASSWORD")
    or die("Could not connect to database:
    ".mysql_error() );
    mysql_select_db ("DATABASE", $db)
    or die("Could not select database: ".mysql_error() );
    >
    However from the linux box I can connect no problems using:
    mysql --host=SERVER -u USER -p
    >
    Can anyone help point me in the right direction to solve this one?
    Cheers
    Dan
    >
    Which version of the MySQL client libraries are being used by
    Apache/PHP? If it's pre-MySQL 4.1, it will use a different password
    hashing algorithm.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • GD

      #3
      Re: mysql_connect error Apache Web server to Windows hosted database


      Jerry Stuckle wrote:
      >
      Which version of the MySQL client libraries are being used by
      Apache/PHP? If it's pre-MySQL 4.1, it will use a different password
      hashing algorithm.
      >
      >From phpinfo():
      Active Persistent Links 0
      Active Links 0
      Client API version 4.1.11
      MYSQL_MODULE_TY PE external
      MYSQL_SOCKET /var/lib/mysql/mysql.sock
      MYSQL_INCLUDE -I/usr/include/mysql
      MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient

      So this is post-MySQL 4.1?

      Thanks
      Dan

      Comment

      • Jerry Stuckle

        #4
        Re: mysql_connect error Apache Web server to Windows hosted database

        GD wrote:
        Jerry Stuckle wrote:
        >
        >
        >>Which version of the MySQL client libraries are being used by
        >>Apache/PHP? If it's pre-MySQL 4.1, it will use a different password
        >>hashing algorithm.
        >>
        >
        >
        >>From phpinfo():
        >
        Active Persistent Links 0
        Active Links 0
        Client API version 4.1.11
        MYSQL_MODULE_TY PE external
        MYSQL_SOCKET /var/lib/mysql/mysql.sock
        MYSQL_INCLUDE -I/usr/include/mysql
        MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient
        >
        So this is post-MySQL 4.1?
        >
        Thanks
        Dan
        >
        Yes, that's post 4.1. In that case I would check your server, userid
        and password in the mysql_connect() statement very closely.

        The fact you can connect from the linux box to the Windows box with
        mysql command line utility indicates MySQL on the Windows box is set up
        for networking OK, no firewalls in place, etc. The mysql_connect()
        statement on the Linux box should use the same type of call.

        The only other possibility I can think of is your command line MySQL on
        the Linux box might be an older version and you're using pre-4.1
        passwords on the Windows MySQL box. "mysql -V" would tell you the
        version you're running on the Linux command line.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • GD

          #5
          Re: mysql_connect error Apache Web server to Windows hosted database

          Jerry Stuckle wrote:
          GD wrote:
          Jerry Stuckle wrote:
          The only other possibility I can think of is your command line MySQL on
          the Linux box might be an older version and you're using pre-4.1
          passwords on the Windows MySQL box. "mysql -V" would tell you the
          version you're running on the Linux command line.
          >
          Hi Jerry,

          thanks for your suggestions, mysql -V reports that I'm running version:

          mysql Ver 14.7 Distrib 4.1.11, for redhat-linux-gnu (i386)

          so again it's post-v4.1.
          I've looked at the servername, user and password and tried all
          permutations, but with no success.
          The only other thing I can think of is there's some sort of permissions
          problem on the files, rather than the database, but I'm just clutching
          at straws now. Any help very gratefully received.

          Cheers
          Dan

          Comment

          • Jerry Stuckle

            #6
            Re: mysql_connect error Apache Web server to Windows hosted database

            GD wrote:
            Jerry Stuckle wrote:
            >
            >>GD wrote:
            >>
            >>>Jerry Stuckle wrote:
            >
            >
            >>The only other possibility I can think of is your command line MySQL on
            >>the Linux box might be an older version and you're using pre-4.1
            >>passwords on the Windows MySQL box. "mysql -V" would tell you the
            >>version you're running on the Linux command line.
            >>
            >
            >
            Hi Jerry,
            >
            thanks for your suggestions, mysql -V reports that I'm running version:
            >
            mysql Ver 14.7 Distrib 4.1.11, for redhat-linux-gnu (i386)
            >
            so again it's post-v4.1.
            I've looked at the servername, user and password and tried all
            permutations, but with no success.
            The only other thing I can think of is there's some sort of permissions
            problem on the files, rather than the database, but I'm just clutching
            at straws now. Any help very gratefully received.
            >
            Cheers
            Dan
            >
            Dan,

            Hmmm, that's possible, I guess. On Linux 13 is "permission denied".
            However, I would think you'd have problems even starting Apache if it
            couldn't read the mysql libs.

            Do you have anything in the [mysql] section of your php.ini?

            Also, looking back through your first message - you indicate you get the
            message:

            Can't connect to MySQL server on 'SERVER' (13)

            But your code puts out the messages:

            "Could not connect to database: ".mysql_error() ;
            and
            "Could not select database: ".mysql_error() ;

            Is this actually the case (your message isn't generated by your code),
            or did you just mistype the message? Just want to make sure we're going
            down the right path :-).



            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • GD

              #7
              Re: mysql_connect error Apache Web server to Windows hosted database


              Jerry Stuckle wrote:
              Dan,
              >
              Do you have anything in the [mysql] section of your php.ini?
              >
              Also, looking back through your first message - you indicate you get the
              message:
              >
              Can't connect to MySQL server on 'SERVER' (13)
              >
              But your code puts out the messages:
              >
              "Could not connect to database: ".mysql_error() ;
              and
              "Could not select database: ".mysql_error() ;
              >
              Is this actually the case (your message isn't generated by your code),
              or did you just mistype the message? Just want to make sure we're going
              down the right path :-).
              >
              The actual message is:

              Could not connect to database: Can't connect to MySQL server on
              'SERVER' (13)

              MySQL section of php.ini copied below.

              [MySQL]
              ; Allow or prevent persistent links.
              mysql.allow_per sistent = On

              ; Maximum number of persistent links. -1 means no limit.
              mysql.max_persi stent = -1

              ; Maximum number of links (persistent + non-persistent). -1 means no
              limit.
              mysql.max_links = -1

              ; Default port number for mysql_connect() . If unset, mysql_connect()
              will use
              ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
              ; compile-time value defined MYSQL_PORT (in that order). Win32 will
              only look
              ; at MYSQL_PORT.
              mysql.default_p ort =

              ; Default socket name for local MySQL connects. If empty, uses the
              built-in
              ; MySQL defaults.
              mysql.default_s ocket =

              ; Default host for mysql_connect() (doesn't apply in safe mode).
              mysql.default_h ost =

              ; Default user for mysql_connect() (doesn't apply in safe mode).
              mysql.default_u ser =

              ; Default password for mysql_connect() (doesn't apply in safe mode).
              ; Note that this is generally a *bad* idea to store passwords in this
              file.
              ; *Any* user with PHP access can run 'echo
              get_cfg_var("my sql.default_pas sword")
              ; and reveal this password! And of course, any users with read access
              to this
              ; file will be able to reveal the password as well.
              mysql.default_p assword =

              ; Maximum time (in secondes) for connect timeout. -1 means no limit
              mysql.connect_t imeout = 60

              ; Trace mode. When trace_mode is active (=On), warnings for table/index
              scans and
              ; SQL-Errors will be displayed.
              mysql.trace_mod e = Off

              Thanks for your help!
              Dan

              Comment

              Working...