I installed MySQL on Mac OS X Mountain Lion with homebrew install mysql, but when I tried mysql -u root I got the following error:
I have tried every possible way to solve this issue, like ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock, uninstall and reinstall mysql, make sure mysql is running on xampp but none of it still worked.
Finally, I open up my.cnf (config file) and copy the socket path (make sure to copy the full path else it won't work). Then I perform this command in my terminal
mysql --socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Lo, and behold, mysql launchs.
This solution will only work if your MySQL is shown running on Xampp/Ampps, but in terminal it is still not connecting to the right socket when you have already attempted something like:
./mysql -u root
or
brew services start mysql
I hope this helps!