Restart the computer in Recovery OS. If you’re using FileVault (which is mandatory for this method to work), wait at the login screen until a message appears that says something like “Use your power button to shut down and start again in Recovery OS.” Hold down the power button, wait a few seconds, then turn it back on.
Connect to the Internet in Recovery OS. If your computer is connected to the Internet with an Ethernet cable (a “wired” connection), you should already be connected to the Internet. To connect to Wi-Fi, move your mouse to the top of the screen to show the Wi-Fi icon, then click it to connect.
Choose an option in the Reset Password screen. When the computer boots into Recovery OS, you’ll see a screen that says “Reset Password” with three options beneath. Choose “I forgot my password” and click “Next.”
Enter your Apple ID and password to log into iCloud. This is your iCloud/Apple Account password, not the username and password you use to log into your computer. Once you log in, Recovery OS will retrieve the password recovery key from the iCloud server.
Reset your password. Once your recovery key is downloaded, enter a new password for your local computer account. Once the password is changed, click “Restart” to reboot the computer. When the computer comes back up, you’ll be able to log in with your new password.
Create a new login keychain. If you see a message that says something like “the system was unable to unlock your login keychain” (it might be different wording on different versions of OSX), click “Create New Keychain.” Follow the prompts and you should no longer see that message. If no Keychain message appears, you should manually create a login keychain by navigating to the Applications folder, selecting “Utilities,” then “Open Keychain Access.” Click “Preferences,” then “Reset my default keychain.”