I faced the same problem couple of times and each time the reason was different:
- The solution that worked first time was that by "Abhishek Oza" which is same as that of "amey91" (see above)
- The second time, my server was on a different port number than the default one(3036),so i was not able to connect.So I had to specify
the port number explicitly for making the connection which you can do
simply by writing: "mysql --host=127.0.0.1 --port=8081(specify your
port number here) mysql -u root -p"