Ηοmebrew is the best package management tool in macOS, but the its maddening frequent updating feature is a main reason of many software issues.
Today when I started MySQL through command
mysql -u root -p
terminal reported an error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Seems only a small issue, but when I looked through all the solutions from differrent forums, this error cannot be solved. Database’s unexpected issues is always complicated. So I prepared to reinstall MySQL and it’s a complex process.
But during the backup preparation before reinstallation. I find the MySQL’s version issue: the command ‘mysql -v’ get a response ‘8.0.19’ but when I used the command
brew info mysql
the result is ‘mysql: stable 8.0.23’. Obviously the version issue is the real problem, but except that I saw another problem
~ brew info mysql......==> Dependencies
Build: cmake ✘
Required: openssl@1.1 ✘, protobuf ✘.....
three dependencies weren’t met for MySQL, maybe the error was caused by Homebrew because all these dependencies and MySQL is installed by it, so I tried to reinstall these openssl and protobuf (camke not included) first rather than reinstalling the whole MySQL, during the reinstallation process homebrew also upgraded the MySQL from 8.0.19 to 8.0.23(so the original brew info result is false), after that I restarted the MySQL services(neccessary)
brew services restart mysqlmysql.server restart
That’s worked, I can start and access MySQL as before using command
mysql -u root -p
In the final analysis it’s a avoidable mistakes caused by the auto update strategy of Homebrew, I don’t need a latest version MySQL which contains many new features but a stable version database, but the strategy forcing users to use the latest version software. Actually this disgusting update process will run once you install any new package. To prevent this update whenever you run a brew command, modify the shell configuration file ~/.zshrc or ~/.bashrc (if you are using bash) with
export HOMEBREW_NO_AUTO_UPDATE=true
donot forget to ‘source’ the file to make it effective.