localhost is your local machine and MySQl server instance by default runs on port 3306, so checkout if that port is opened and any service is running on it. Use netstat command from command prompt to check any process running on port 3306.
When I installed it successfully, my code didn't show the desired answer.
so I removed and reinstalled MySQL and since then, even if I enter correct existing password followed by new password and confirm it.
It shows me Error no 2003, "Can't connect to MySQL server on localhost(10061).
I checked the process MySQL, but it stops within a moment after starting through control panel.
when I do the same through command prompt by giving sc qc MySQL, it shows me access denied when I'm the admin of the machine.
Unfortunately I'm unable to attache word file here ...