Yosemite - MAMP - Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
Asked Answered
D

8

13

I have problem when I try to connect to MySQL MAMP :

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

I'm doing research but I have not found a solution to my problem, I try to link mysql.sock like this :

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

But, the file /tmp/mysql.sock doesn't exist.

Do you have any ideas ? The problem is blocking me for 2 days, I searched for this time but nothing good for me.

Thanks in advance,

Devonna answered 6/11, 2014 at 10:1 Comment(2)
Possible duplicate of Error #2002 Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)Housekeeper
you have to start the sever first. so click on the blue elephant status icon in the menubar and select Start servers then the MAMP will create a socket in the tmp file.Richey
C
5

I had the same problem. I solved it following these steps:

  1. I stopped and restarted MySQL via System Preferences -> MySQL (see also https://mcmap.net/q/902892/-how-to-get-mysql-server-working-after-osx-yosemite-upgrade)
  2. I entered sudo mysql_upgrade in a terminal window, and pressed enter

After the update process I was able to connect with my MySQL.

Caduceus answered 10/1, 2015 at 13:57 Comment(0)
G
19

I had the same problem after upgrading MySQL on MAMP from 5.5 to 5.6 version. After long research I founded this decision https://drupal.stackexchange.com/questions/32402/drush-and-mysql-database-with-mamp-connection-problem

In my case there was no socket file at that location /Applications/MAMP/tmp/mysql/mysql.sock.

The easy solution is to create a symlink:

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

The effect of which is to route all calls for /tmp/mysql.sock to the appropriate MAMP specific path.

Genesa answered 26/9, 2016 at 10:29 Comment(1)
This helped me !! Thanks a ton Galina. I tried all suggestions in this chain but finally, yours helped me. It may be useful to explain a little more why this problem occurs in the first place and why was this link you suggested not created by default?Anchie
T
15

simply remove two files ib_logfile0 and ib_logfile1 from /Applications/MAMP/db/mysql56

Toweling answered 23/6, 2017 at 0:24 Comment(1)
Works like a charm in High Sierra! Thanks!Cabanatuan
S
9

In some cases /Applications/MAMP/tmp/mysql/mysql.sock.lock may create the problem. remove .lock and it will work (OSX)

Sepulchre answered 21/3, 2020 at 9:45 Comment(3)
Your Rock! save my dayImprint
In my case, completely removing the mysql.sock.lock file worked.Untwine
none of the above method works, only your is working. thanks a lot!Arkwright
C
5

I had the same problem. I solved it following these steps:

  1. I stopped and restarted MySQL via System Preferences -> MySQL (see also https://mcmap.net/q/902892/-how-to-get-mysql-server-working-after-osx-yosemite-upgrade)
  2. I entered sudo mysql_upgrade in a terminal window, and pressed enter

After the update process I was able to connect with my MySQL.

Caduceus answered 10/1, 2015 at 13:57 Comment(0)
S
2

Rename .sock file of mysql and restart your MySQL server.

/Applications/MAMP/tmp/mysql/mysql.sock to /Applications/MAMP/tmp/mysql/mysql_old.sock

Splashy answered 6/11, 2014 at 10:4 Comment(3)
renaming the mysql.sock did not help me.Anchie
share your error here.. exactly what you are getting.Splashy
@AaronMarton :-)Splashy
M
2

Also check to make sure MySql is running. You can get this error if you try to use MySql from the command line when MAMP/MySql is not running.

Mastectomy answered 29/7, 2015 at 16:30 Comment(0)
L
0

In case this helps anyone, I got past this roadblock by:

  1. Stopping all other versions of MySQL (I forgot that I had Oracle MySQL starting on system launch and I was attempting to connect via that installation.) and removing them anyway to let MAMP handle it.
    Use sudo launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
  2. Ensure MAMP is running.
  3. Running /Applications/MAMP/Library/bin/mysql.
Larva answered 11/12, 2015 at 16:3 Comment(1)
Tried to shut down oracle MySQL but this still did not help starting the MAMP MySQL.Anchie
C
0

1) mysql.server stop

2) /Applications/MAMP/bin/startMysql.sh &&

now on MAMP go to

Tools => Upgrade MySQL databases

Chaing answered 28/4, 2020 at 16:54 Comment(1)
You can't upgrade the database if it won't start.Mimesis

© 2022 - 2024 — McMap. All rights reserved.