If you get the above error message when you try to connect on MySQL server through command prompt (or terminal), then check for the following things,
1. Check if mysql process (server demon) is running.
2. Check your firewall settings.
3. Do a Telnet <host ip/name> 3306.
4. If step 3 works you should get a response as server version details, if it doesn't work then telnet: Unable to connect to remote host: Connection refused message is displayed. Try changing 3306 Default MySQL port to some different port number.
5. Check that the bind-address = 127.0.0.1 in my.conf configuration file (try commenting out bind-address and restarting mysql server may work).