-
Open the Terminal
-
Use
mysqldump
to backup your databases -
Check for MySQL processes with:
ps -ax | grep mysql
-
Stop and kill any MySQL processes
-
Analyze MySQL on HomeBrew:
brew remove mysql brew cleanup
-
Remove files:
sudo rm /usr/local/mysql sudo rm -rf /usr/local/var/mysql sudo rm -rf /usr/local/mysql* sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm -rf /Library/PreferencePanes/My*
-
Unload previous MySQL Auto-Login:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
-
Remove previous MySQL Configuration:
# Edit this file: /etc/hostconfig # Remove the line MYSQLCOM=-YES-
-
Remove previous MySQL Preferences:
rm -rf ~/Library/PreferencePanes/My* sudo rm -rf /Library/Receipts/mysql* sudo rm -rf /Library/Receipts/MySQL* sudo rm -rf /private/var/db/receipts/*mysql*
-
Restart your computer just to ensure any MySQL processes are killed
-
Try to run mysql, it shouldn't work
-
-
Save vitorbritto/0555879fe4414d18569d to your computer and use it in GitHub Desktop.
This helped. I also had the ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
and also had to remove rm /usr/local/etc/my.cnf
.
Thanks.
Thanks bro! This helped
Do reboot else it wont work
This helped immensely a couple months ago, and I finally went back to document the fix in my field manuals for Homebrew and Valet Plus:
I did all the process and worked then I installed again the mysql
$ brew install mysql $ brew tap homebrew/services $ brew services run mysql
And everything start work until today, where I tried to run my local website (as any other day) and I got:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
After that, every answer that I tried takes me to another error and so on. This is not the first time that happened and the only solution is re-install everything. So I was wondering if anyone have any idea why this could be happening. I don't want to run the entire process every time that mysql decide crash, but I want fix the problem or at least understand what is going on.
sequelize/cli#572hey dear you can fix your problem by running
mysql.server start
Has anyone managed to solve this? This happened suddenly to me, and mysql server became unstable, and I couldn't connect to it (giving the same error mentioned).? and would I face this still even if I reinstalled?
Regarding Step 6:
sudo rm -rf /Library/PreferencePanes/My*
Is it necessary to use such a wildcard here, instead of a more explicit pattern? MySQL can't be the only thing (now, or in the future) that a user might have in /Library/PreferencePanes that begins with My
, right?
Thanks a lot. I followed the same procedure. But when I typed mysql
I was getting ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
. I used sudo rm -rf /usr/local/bin/mysql*
. That worked.
Can you clarify on step 4? I try killing the process but it mysqld won't die it'll show up under a new id
@QubeChan — I had the some problem. Documented here: https://manuals.gravitydept.com/develop/command-line/brew
I skipped it and didn't have issues with the remaining steps.
Thanks for posting
It saved my many days. thanks
Thank you. Great post! Saved a lot of time
Good post. I defaulted to install DBngin and it worked for me.
Thanks this got it all working!
Helped a lot, thank you!
After long searching , i solved this issue , downloaded official mac os community file from :- https://dev.mysql.com/downloads/file/?id=492745
it worked for mac os Catalina 10.15 , check this link :- https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/osx-installation-pkg.html , they also mentioned required packages to run mysql on mac os , specially "/tmp/mysql.sock" at bottom .
Saved my behind.
This was very helpful. I also had to do:
rm /usr/local/etc/my.cnf
Something I had done previously had resulted in a
my.cnf
file that prevented MySQL from working (I was getting the dreadedERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
error).
Apparently, this config file can live in several places: /etc/my.cnf, OR /etc/mysql/my.cnf OR ~/.my.cnf. My particular install had placed it at /etc/my.cnf as well, but thought I'd drop the other options here in case anybody else is down this same rabbit hole as me one day.
Thanks to OP @vitorbritto for the great gist as well!
Thanks, it worked :-)
Thanks
how do we do step 8... removing the line part
Thanks a lot. It would have been good if I got this article first. I would have saved about 5 hours :-(
Thank you so much. I wish I had landed up on this page much earlier. I struggled so much. This is an excellent page, Thanks 👍
Thank you! Very helpful!
Thank you very much. It is notoriously difficult to uninstall mysql data. Your tutorial did the trick! 👍
subl /etc/hostconfig`
has a hanging backtick
👍
thank you very much
Thank you , it's help a lot !
This was very helpful. I also had to do:
rm /usr/local/etc/my.cnf
Something I had done previously had resulted in a
my.cnf
file that prevented MySQL from working (I was getting the dreadedERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
error).