Suddenly after restarting the machine, I have been facing this error can't connect to MySQL server and table plus is not able to connect with localhost 127.0.0.1.
The steps below worked for me, and can probably work for you, too! However, you will need to install HomeBrew if you don’t have it already.
brew doctor brew remove mysql
Above remove mysql will not remove databases, So you can easily run the above commands.
brew install mysql
Once you installed the latest version of mysql then try to see the folder of mysql installation by running
which mysql
It should show like this one "/opt/homebrew/bin/mysql" The final step should be writable permissions for the mysql var folder by running
chmod -R 0777 /opt/homebrew/var/mysql
This has resolved socket and PID error for me.