SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Gilroy, CA
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't connect to local MySQL server through socket '/tmp/mysql.sock'

    I've just installed apache and php succesfully on RedHat 7.0.
    PHP is running fine with apache but I get this error when I try to connect to MySql:

    Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) in /usr/local/apache/htdocs/test.php on line 6

    test.php =
    My test file for php support


    <?php

    $link = mysql_connect ("localhost", "root", "mypassword")
    or die ("Could not connect");
    print ("Connected successfully");
    mysql_close ($link);

    ?>

    Here's the kicker. Ive been running Mysql on this machine for a while, I installed it from an RPM. The database is currently in use for my business and I don't want to reinstall it from tar if I don't have to.

    The only clue I have is when installing php from a tar file, I specified only "--with-mysql". If I try to supply a path to mysql I cannot find one that works. The ./configure complains:

    checking for MySQL support... yes
    configure: error: Cannot find header files under /usr/var/mysql

    I've also tried specifying paths to /usr/bin

    These are the only places I can find anything related to mysql.

    I'm concerned that the header files don't come with the RPM.

    One more kicker. If I put "phpinfo()" in my page and look through the results, it does display the correct version of MySql in the results:

    mysql
    MySQL Support enabled
    Active Persistent Links 0
    Active Links 0
    Client API version 3.23.32
    MYSQL_INCLUDE
    MYSQL_LFLAGS
    MYSQL_LIBS

    Directive Local Value Master Value
    mysql.allow_persistent
    On On
    mysql.default_host
    no value no value
    mysql.default_password
    no value no value
    mysql.default_port
    no value no value
    mysql.default_socket
    no value no value
    mysql.default_user
    no value no value
    mysql.max_links
    Unlimited Unlimited
    mysql.max_persistent
    Unlimited Unlimited

    This makes me think it php is configured OK for mysql because it found it.

    Any thoughts?
    Thanks
    Bernn
    bernnhugh@yahoo.com

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Gilroy, CA
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Answer to can't connect on /tmp/mysql.sock

    I answered my own question, but I've seen the error pop up on the newsgroups so I'll pass it along for the next poor guy.

    Edit your php.ini file to point to the actual location of your mysql.sock. You can find the location of mysql.sock with mysqladmin variables.

    For the record, mysql was installed from an RPM - that has nothing to do with it.

    PHP was configured --with-mysql , no path added.

  3. #3
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeppo! Thanks for sharing this bit of information! First search!
    It's probably a very common problem
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •