ERROR 2002 (HY000) while using brewed mysql
Asked Answered
S

2

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 [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!

Sardou answered 31/5, 2020 at 9:49 Comment(5)
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 workaroundAmadavat
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?Geminius
Can you post the mysql error log content? At least the last 50 linesHigginbotham
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?Herpes
@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.sockSardou
A
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
Alb answered 26/6, 2020 at 6:11 Comment(2)
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.Alb
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?Sardou
O
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
Ori answered 26/6, 2020 at 7:18 Comment(2)
So you basically are saying that this question is a duplicate, why answer by linking another answer?Veinlet
on "brew doctor" I don't get such suggestions to fix the permission issues.Sardou

© 2022 - 2024 — McMap. All rights reserved.