Can't connect to MySQL on Mac — missing mysql.sock file

前端 未结 7 886
醉话见心
醉话见心 2020-12-16 04:10

I installed MySQL on my Mac OS 10.6 about a week ago, and, after some playing around, got it to work just fine. It integrated with python MySQLdb and I also got Sequel Pro

相关标签:
7条回答
  • 2020-12-16 04:32

    I was getting some similar error and ended up here. I am using OSX 10.9.5. This solved my problems (hope it helps someone).

    1) sudo mkdir /var/mysql

    2) sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

    More informations: http://glidingphenomena.blogspot.com.br/2010/03/fixing-warning-mysqlconnect-cant.html

    Thanks!

    0 讨论(0)
  • 2020-12-16 04:35

    Ok, I just spent a couple hours struggling with this same problem. I had installed the dmg file for MySql 5.5.20 (64bit) for osx 10.6 on my iMac with OSX 10.7.2 - and the /tmp/mysql.sock was missing!

    The answer turned out to be simply install the MySQLStartupItem.pkg that comes with the dmg file and restart the system. This starts up the daemons upon startup (which I hoped would be optional).

    Magically, my /tmp/mysql.sock file appeared and all is well!

    0 讨论(0)
  • 2020-12-16 04:41

    Found the solution:
    I had the same issue and I did a lot of searches but couldn't solve the issue until I looked at my MySql config file. In my config file socket was in line 21 and the path was
    "/Applications/AMPPS/var/mysql.sock"

    In Ampps application click on MySql tab and then click on configuration button.

    You can also find the config file in "/Applications/AMPPS/mysql/etc" folder

    So simply I added
    'unix_socket' => '/Applications/AMPPS/var/mysql.sock',
    to my database.php in mysql array and it's worked for me.
    After host line. I have tested with localhost and 127.0.0.1 and both worked
    Hopefully it's working for you too.

    0 讨论(0)
  • 2020-12-16 04:43

    First of all I suggest you to use homebrew to install any third part libraries or tools on your mac. Have a look to : http://mxcl.github.com/homebrew/

    Otherwise for your problem you can search where is the mysql socket on your mac and then symlink it to /tmp.

    In your terminal try something like :

    locate mysql | grep sock
    

    You will get something like :

    /the/path/to/mysql.sock
    

    Then do :

    ln -s /the/path/to/mysql.sock /tmp/mysql.sock
    

    This should works.

    Also you can edit your php.ini file to set the correct path for the mysql socket.

    Hope this help.

    0 讨论(0)
  • 2020-12-16 04:45

    I am going to throw in my two cents here because I had this problem too but my circumstances are abnormal for most. My system had a blended install of Zend Server CE and XAMPP. I am running Mac OS X. And I decided to remove Zend from my system because it was being a pain in my butt.

    Upon removing Zend, since both were using the same DB and Zend had it my system went crazy. Uninstalling and reinstalling XAMPP didn't help. After a couple hours (which I just literally got done with) of troubleshooting I found that I needed to search my system for all copies my.cnf. The reason being is that mysql still kept trying to look for the Zend mysql path and it was failing.

    So I used locate to find it. I had to initiate locate (since I had never used it before) so that it could build a DB of files on my system. Then I ran "locate my.cnf" and I found one in "/private/etc". So I just renamed the file to my.cnf.old and tried to launch MySQL again. Bam! It works now.

    I will say this, I had to have a co-worker help me out because I was just spinning my wheels on this one. I really hope this helps someone out there. Thanks!

    0 讨论(0)
  • 2020-12-16 04:48

    If you have installed mysql through homebrew, simple brew services restart mysql may help.

    0 讨论(0)
提交回复
热议问题