7
votes

I was using MAMP and have removed it completely from my MAC OS. Post this,

  1. I installed mysql5.7 using brew
  2. Added mysql path to zshrc / bash profile
  3. Started mysql service using brew services start [email protected]

Now when I try to access mysql on command line it gives me error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)

Where as I have already added socket path to /tmp/mysql.sock in my.cnf as well as tried creating symlink of same to ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2) but no luck.

Advice on same will be highly appreciated!

2
reading bugs.mysql.com/bug.php?id=61011 and getsymphony.com/discuss/thread/82299/#position-7 are there no files to configure this globally? or maybe symlinking the file with ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock as a workaroundJoSSte
Did you have any previous installations of MySQL like MAMP or XAMP? Do you see the MySQL service running when you run brew services list?Christos Lytras
Can you post the mysql error log content? At least the last 50 linesJesus Uzcanga
your socket is at /tmp/mysql.sock ? Is this an absolute path? and the error searches at /tmp/mysql/mysql.sock? or /Applications/MAMP/tmp/mysql/mysql.sock?Ron
@ChristosLytras - Yes as I was using MAMP so had mysql service from MAMP stack Ron - Mysql service looks for socket on /Applications/MAMP/tmp/mysql/mysql.sockRizwan Dhuka

2 Answers

0
votes

this is a sign that the server did not really start. Run:

ps aux|grep mysql

If you find a mysql server process , there are chances is not correctly installed.

the best is to uninstall, if you don't have anything important in the database and reinstall it again . You could try reinstall , but this is usually not fixing the issue.

brew services list 

brew uninstall mysql@YOUR_VERSION

brew install mysql@DESIRED_VERSION
0
votes

[1] I faced a similar issue a few weeks ago, the fix was changing my brew permissions. Try some of the answers in this stackoverflow answer and the rest of the thread:

sudo chown -R $(whoami) $(brew --prefix)/*

[2] Brew tells you a bunch of folders having permission issues and the fix for each of them. Run commands mentioned in brew doctor and it should work. Here is what my brew doctor had to say:

You should change the ownership of these directories to your user.  
> sudo chown -R $(whoami) /usr/local/Cellar /usr/local/Frameworks /usr/local/Homebrew /usr/local/bin /usr/local/etc /usr/local/etc/bash_completion.d /usr/local/include /usr/local/lib /usr/local/lib/pkgconfig /usr/local/lib/python3.7/site-packages /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/linked /usr/local/var/homebrew/locks /usr/local/var/log

And make sure that your user has write permission.
> chmod u+w /usr/local/Cellar /usr/local/Frameworks /usr/local/Homebrew /usr/local/bin /usr/local/etc /usr/local/etc/bash_completion.d /usr/local/include /usr/local/lib /usr/local/lib/pkgconfig /usr/local/lib/python3.7/site-packages /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/aclocal /usr/local/share/doc /usr/local/share/info /usr/local/share/locale /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7 /usr/local/share/man/man8 /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew/linked /usr/local/var/homebrew/locks /usr/local/var/log