[MySQL] How to create a .sock file?

Discussion in 'Linux & BSD' started by Glaanieboy, Nov 26, 2004.

  1. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I got an Apache2/php4/MySQL4.0 installation running on my Slackware Linux box. All is installed fine, but I got one little issue. PHP refuses to connect to MySQL, this error occurs:
    I peeked into /var/run/mysql/ and the file isn't there, only mysql.pid.
    I have checked the rights for that dir, they are 755 for user mysql and group mysql, so it should be able to wrote to that dir upon startup. How can I fix this problem?
     
  2. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Check /tmp for a mysql.sock

    Then check your php.ini and point it at the right location.

    It should also contain an option to disable sock operations, and instead just connect on a certain port, for this, also check PHP.ini.

    You could always if it is in /tmp:

    cd /var/run/mysql/
    ln -s /tmp/mysql.sock

    And be done with it. Butthat is up to you.

    X-Istence
     
  3. j79zlr

    j79zlr Glaanies script monkey Political User

    Messages:
    2,725
    Location:
    Chicago
    This can be caused if you do not have an /etc/my.cnf file
     
  4. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    it would fall back to the standard location, which is either /tmp or /var/tmp

    X-Istence
     
  5. j79zlr

    j79zlr Glaanies script monkey Political User

    Messages:
    2,725
    Location:
    Chicago
    try it ;)

    <<edit>>

    Hmmm mysql restarted without the my.cnf file, I would swear it wouldn't, I know it wouldn't used to.
     
  6. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I did have a my.cnf file in my /etc dir, so that wasn't the case. I set the mysql.default.socket option to /tmp/mysql.sock and all was good again. I was used to FreeBSD porting system, where all the options are set correctly, guess compiling from source takes a bit more configuring. Anyway, another thing learnt, it's getting more fun!
     
  7. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    You swear it would not? It does on my 3.x install which is running on BSD. Same thing with the new 4.1 and the bit older 4.0.

    See i knew this for one reason only, because the FreeBSD ports tree does not add a standard my.cnf anywhere, so there is nothing to read from. This means it has to somehow do it from some standard it has either compiled in at compile time, or because it was hard coded in the code.
     
  8. j79zlr

    j79zlr Glaanies script monkey Political User

    Messages:
    2,725
    Location:
    Chicago
    Yea, but I remember sepcifically having that promlem where it couldn't create the socket file until I copied one of the my.cnf default files into /usr/local/etc/. This was with MySQL 3.x years ago.

    MySQL installs example my.cnf's into /usr/local/share/mysql/
     
  9. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Hrm, never had that problem. If permissions were wrong on /var/tmp to create a mysql.sock it would fall back to /tmp which almost always will allow a socket to be created.