Connect to MySQL TCP instead of a socket
Do not use localhost - use 127.0.0.1 instead. Many clients have an internal alias that makes them connect to the socket if you specify localhost as target.
Specify that you want to use TCP and not a socket (mysql --protocol tcp)
You can also easily make that the default my editing your my.cnf so it has this ([client] means any client: