STEP 1:
Press the power button and holding down Command + R. The Mac will boot into Recovery mode.
STEP 2:
When you see the load bar appear you can let go of the keys. It may take a few minutes to load.
Select Disk Utility and press Continue.
STEP 3:
Choose Utilities > Terminal.
STEP 4:
Enter the command in terminal resetpassword and press Return.
STEP 5:
Select the volume containing the account (normally this will be your main hard drive).
STEP 6:
Choose the account to change with Select the User Account.
STEP 7:
Enter a new password and re-enter it into the password fields and Click Save.
STEP 8 :
A warning will appear that the password has changed, but not the Keychain Password. Click OK.
STEP 9:
Click Apple > Shut Down.
STEP 10:
Now start up the Mac. You can log in using the new password.
Courtesy : macworld