Enter OS X Recovery Mode
To boot into OS X Recovery, the first thing you need to do is to restart your Mac. While restarting, hold down CMD + R until the Apple logo appears. If you time it right, you will enter the recovery mode.
What you need to do next is to go to Utilities > Terminal to open a Terminal. In Terminal, type
resetpassword and press Enter.
You will now be presented with the Reset Password window. Next, select your OS X drive. From the drop-down under “Select the user account:”, choose the user account that you want to reset password for.
Type in your new password, re-enter it and try not to forget it this time. You can also choose to write down a hint in the “Enter a new password hint for this user (optional)”, just in case.
Once you’re done, click on Save. You will be prompted with this message saying that your user account password was reset but your keychain is not. Just click OK and close all windows.
Now click the Apple icon at the very top left and choose Restart. You can now enter your account with your new password.