If you forget your OS X account password then it can be reset by either another user, provided they have administrator privileges, or through OS X Recovery.
A new password recovery feature introduced with OS X Lion is the option of assigning an Apple ID to your OS X user account. Should you forget your password or if it has been changed without your knowledge, you can reset it yourself without the assistance of another user or the process of booting the Mac into OS X Recovery.
OS X Lion and above have included a feature to link an Apple ID to your Mac’s local user account for the purpose of resetting a forgotten password. The benefit of using this is that you don’t need anyone else’s assistance to reset your password, nor be concerned with using OS X Recovery.
For Mac system administrators, allowing users to tie their Apple ID to their local OS X account can mean fewer password reset requests since the user can just do it themselves.
Linking an Apple ID
To link your Apple ID to your OS X user account, launch System Preferences and select Users & Groups.
Select your user account and in the section for Apple ID, click Set…. Enter your Apple ID and password when prompted.
Finally, make sure to check the option Allow user to reset password using Apple ID.
Resetting a Password with an Apple ID
Back at the OS X login window, if the password is entered incorrectly a number of times then a message will appear asking if you’d like to reset your password using your Apple ID.
Click the ▸ button to continue the process of resetting your Mac password.
Enter your Apple ID credentials and click Reset Password. A warning dialog will appear explaining that a new Keychain will be created since OS X prevents the Keychain password from being reset.
After confirming, you can then specify a new password for your OS X account. Once verified, click Reset Password.
A Note about Keychain
On the first time you log in after resetting your password using any method, not just with an Apple ID, OS X may display a message about being unable to access your Keychain. Since your Keychain password can only be changed and not reset, you’ll need to select Create New Keychain. If you opt to continue logging in, you’ll simply be bombarded with messages about various apps and services being unable to access the Keychain.
As you may have confidential passwords and information stored within your Keychain, OS X explicitly requires a password and it cannot be reset. This security feature is by design so that someone cannot maliciously reset your OS X password, log in and then find out all your other passwords for services such as online banking that may have been saved.
If you do reset your user account password, OS X will have no choice but to create a new Keychain for your user account and any saved passwords for apps like Twitter will have to be entered again. The old Keychain will not be deleted but is inaccessible unless the old password can be provided.