Monday, December 26, 2005

MySQL error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

A friend of mine was getting the following error and called me up. After telling him how to fix it, I decided to post it here too.
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
The solution was simple, just start MySQL :)

--
Did you know you can help educate the world through your bookmarks? Join my alpha project featuring social media tools (OpenEncyclopaedia.com) and share your bookmarks while educating the world.

11 comments:

  1. OS error code 13: Permission denied

    Therefore, the above definitely not THE ONLY cause.

    But, one of the cause.

    ReplyDelete
  2. Thanks Smile Dreamz for pointing it out. I wasn't able to publish your comment because I am in the process of moving.

    Error code 13 can be caused if:

    - user/host permissions are wrong
    - file permissions are wrong
    - mysql not running

    Thanks again
    Frank

    ReplyDelete
  3. Anonymous10:53 AM

    there is another case when you get this error even if mysql server is running. You should check if you compiled PHP with --enable-sockets option

    ReplyDelete
  4. Anonymous8:46 PM

    frankly speaking I have been looking for hours for a solution to the mysql.sock (13) error and with your three lines you provided enough clues as to how to correct the problem. In my case the problem was in fact a user (group) permission error and not any one the many other possible problems. Thanks again for your insight.

    ReplyDelete
  5. With fedora 6 you need disable SE Linux !

    ReplyDelete
  6. Thanks, Boris for the big help.

    I have Fedora 3 with SELinux enabled, which was also the problem. The solution was to set "SELINUX=disabled" on the the configuration file /etc/sysconfig/selinux.

    More info about disabling SELinux here:
    http://docs.fedoraproject.org/selinux-faq-fc3/index.html#id2825945

    ReplyDelete
  7. Anonymous1:41 AM

    Re-iterating Phil,

    THANKS BORIS,

    Without you, I would never have thought of a potential problem with selinux enabled.
    But indeed I had one.

    ReplyDelete
  8. Anonymous5:47 PM

    mysql.sock (13) error

    the true answer, it's here:

    http://docs.fedoraproject.org/selinux-faq-fc3/index.html#id2825945

    ReplyDelete
  9. Anonymous5:32 PM

    Tanks!! the solution for this problem is: DISABLE SELINUX

    ReplyDelete
  10. Anonymous6:09 AM

    Thank you so much! I spent over an hour trying to find this problem. selinux was the problem.

    It it helps anyone:
    * I was connecting to a remote SQL server
    * Connected to SQL server fine from other sources
    * Connected fine from web server using mysql command line
    * Connected fine from web server using php in command line mode
    * Would NOT connect from web server using php from page running under apache

    ReplyDelete
  11. Hi,
    thanks a lot.. your solution was very useful. I tried many other options on my application but nothing worked. Simple yet very useful.

    ReplyDelete