It happens to every Mac user at some point – you create a new password and forgot this password to login your Mac OS X computer. In this tutorial, I'll introduce 2 methods on how to reset any user account password on your Mac.
If you have the Mac OS X installer CD handy, it's super easy to change the administrator account's password. Just insert the CD into the target Mac and hold the "c" key as you boot up the computer. It will boot into the Mac OS X installer. If the computer in question doesn't have a CD drive, you can either hold "Option" at boot and choose the "Recovery partition" at startup, or put the Mountain Lion or Mavericks installer on a flash drive.
Once it does, head up to Utilities in the menu bar and choose "Password Reset".
You'll get a window prompting you to select the drive on which OS X is installed; so choose the drive you want to get into and select the user whose password you want from the drop-down menu. If you're using the Mountain Lion installer, you won't see this menu item. Instead, choose Terminal from the menu, type in "resetpassword", and press "Enter" to get to the password reset menu. Enter a new password for that user and hit the save button. That's it!
When you reboot the computer, you can use your new password to log into the computer.
If you don't have an installer CD, you can achieve the same end as the CD method by a bit of commend-line footwork.
Boot up the computer, holding "Command" + "S" as you hear the startup chime.
The Mac will boot into Single User Mode you will need to mount the volume you need to get into. Most of the time this will just be your boot disk and can be mounted as "/". This command will mount that for you:
Next we need to remove the file that tells OS X that its already done the setup:
Now we need to reboot using the very logical reboot command.
Once we boot back up it will be just like the first time you boot after install and you will see the Welcome screen, and just click through the first two screens.
When you reach the screen that asks if you already own a Mac, make sure to choose "Do not transfer my information now" since we're not doing any migrating of data.
Once you reach the "Enter Your Apple ID" screen, you can press the Command and Q keys at the same time to get past the rest of the prompts. Click "Skip" when asked.
Now you will create a new Administrator account. You can choose to name it something you wish to keep or anything since you just need this account to get into the OS and to System Preferences.
Click through the next screens until you reach the Thank You screen, and we're finally done with that part of the process. Click Go and you'll be brought into the new account.
Once the new account has loaded you can now go to your System Preferences. We will want the Accounts pane.
Now select the account with the password you want to reset and click Reset Password…
Choose your new password, and password hint if you desire, and click Reset Password.
If you're using a Windows PC and forgot your password, you can do so easily by refer this article how to find lost Windows password.