mac homebrew mysql error 2002

This problem has happened many times. As long as you use homebrew to manage mysql, you will definitely lose mysql.sock, and you will always encounter error 2002 (HY000) in the end. The solutions are strange, but not necessarily useful. I have only one conclusion. Homebrew is unreliable, why didn't Apple buy it? Think about it.

Look at this stupid discussion, it still happened eight years ago. Can't connect to local MySQL server through socket homebrew