Snippet: Restarting a brew-installed mysql server

Getting this annoying error?

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)  

If you installed MySQL through Homebrew, you can restart the server via:

$ /usr/local/Cellar/mysql/5.7.17/bin/mysql.server restart     

 ERROR! MySQL server PID file could not be found!
Starting MySQL  
..... SUCCESS!

Or simply:

$ mysql.server restart