7

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 mysql@5.7

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!

Rizwan Dhuka
  • 146
  • 4
  • reading https://bugs.mysql.com/bug.php?id=61011 and http://www.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 workaround – JoSSte Jun 19 '20 at 11:09
  • 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 Jun 19 '20 at 16:11
  • 2
    Can you post the mysql error log content? At least the last 50 lines – Jesus Uzcanga Jun 22 '20 at 14:50
  • 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 Jun 26 '20 at 01:37
  • @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.sock – Rizwan Dhuka Jun 29 '20 at 18:32

2 Answers2

0

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
detzu
  • 566
  • 5
  • 10
  • you have a config file in the path somewhere. check the path and my.conf or search for every *.conf file that has the /Applications/MAMP/tmp/mysql/mysql.sock in it. – detzu Jun 29 '20 at 18:55
  • Appreciate your prompt response but I have already checked configuration files related to mysql and could not find MAMP mysql.sock reference in it. Is there any references in Apple start/load services that I need to modify to remove MAMP mysql reference? – Rizwan Dhuka Jun 30 '20 at 04:06
0

[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
TheChetan
  • 3,887
  • 3
  • 27
  • 36