Error #2002 Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

前端 未结 6 1264
Happy的楠姐
Happy的楠姐 2020-12-01 16:48

I\'m running MAMP.
It has been working fine up until yesterday. I haven\'t been able to find anything that helps so far. But here is my problem:

As the title

相关标签:
6条回答
  • 2020-12-01 17:03

    I faced the same problem. When i start MAMP separately, then the problem gone. And issuing following command worked fine.

    mysql -u root -p
    
    0 讨论(0)
  • 2020-12-01 17:04

    If you'd rather avoid changing ports through MAMP or options in my.cnf file, it might be useful to try forcing a TCP connection via the following on the command line:

    /Applications/MAMP/Library/bin/mysql -h 127.0.0.1 -P 8889 -u root

    Remembering to set the port is important if it's anything other than the mysql default of 3306.

    The -P parameter allows you to set the port.

    MAMP's default port is 8889, but you can verify what yours is set to easily via the MAMP WebStart page while MAMP is running:

    http://localhost:8888/MAMP/

    It'll look similar to this:

    0 讨论(0)
  • 2020-12-01 17:06

    I know this is late, but if ever someone is searching this (as I was tonight, but I found the solution), here's what worked for me:

    I opened MAMP and had to click "USE default Apache and MySQL ports". (80 and 3306 instead of 8888 and 8889). That seemed to fix the issue.

    0 讨论(0)
  • 2020-12-01 17:06

    Silly solution... But in my case, I didnt start the mysql server. So, look that also!

    0 讨论(0)
  • 2020-12-01 17:07

    Test

    If you attempt to start MySQL using the full path it should work

    /Applications/MAMP/Library/bin/mysql -u root -p
    

    Fix

    If that works, then you can set it to work normally by running

    sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
    

    Resolution

    Now MySQL should work normally

    mysql -u root -p
    
    0 讨论(0)
  • 2020-12-01 17:22

    Mysql server has not started.

    mysqld stop
    mysql.server start
    
    0 讨论(0)
提交回复
热议问题