A
First, make sure caps lock is not on.
Another reason why the password might not be recognized is that the keyboard layout (input source) has been switched without your realizing it. You can select one of the available layouts by choosing from the flag menu in the upper right corner, if it's showing, or cycle through them by pressing the key combination command-space or command-option-space. See also this support article.
If the user account is associated with an Apple ID, and you know the Apple ID password, then maybe theApple ID can be used to reset your user account password. In OS X 10.10 and later, this option also works with FileVault, but only if you enabled it when you activated FileVault. It's not retroactive.
Otherwise*, start up in Recovery mode. When the OS X Utilities window appears, select
Utilities ▹ Terminal
from the menu bar at the top of the screen—not from any of the items in the OS X Utilities window.
In the window that opens, type this:
resetp
Press the tab key. The partial command you typed will automatically be completed to this:
resetpassword
Press return. A Reset Password window opens. Close the Terminal window to get it out of the way.
Select the startup volume ("Macintosh HD," unless you gave it a different name) if not already selected. You won't be able to do this if FileVault is active.
Select your username from the menu labeled Select the user account if not already selected.
Follow the prompts to reset the password. It's safest to choose a password that includes only the characters a-z, A-Z, and 0-9.
Select
▹ Restart
from the menu bar.
You should now be able to log in with the new password, but the Keychain will be reset (empty.) If you've forgotten the Keychain password (which is ordinarily the same as the login password), there's no way to recover it.
*Note: If you've activated FileVault, this procedure doesn't apply. Follow instead these instructions.
B
With the Power Nap feature enabled, the computer enters a so-called standby mode after it has been in sleep on battery power for more than a certain time (one hour, by default.) In that mode, the contents of memory are saved to a file, and then the power is turned off. When the computer wakes up, the contents of memory are restored from the file. As a result, waking from sleep takes longer than it otherwise would. The benefit is that sleep can be prolonged indefinitely without draining the battery or having to restart the computer.
Late-model Macs are configured to enter standby after four hours in sleep while on AC power, in order to comply with a directive of the European Union. That behavior doesn't depend on the status of Power Nap.
You have three choices. One is to do nothing. Use the machine as designed. That's what I recommend.
The second choice is to disable Power Nap in the Energy Saver pane of System Preferences. Uncheck the box marked Enable Power Nap... in each of the tabs. You won't get the wake delay anymore, but you won't get any of the features of Power Nap either. The wake delay while on AC power won't be affected.
The third choice is to increase the delay before standby mode is triggered, or to disable standby mode completely. This is an unsupported option and you're on your own as to the consequences. If you choose to go this route, proceed as below. These instructions are for advanced users only.
Back up all data before making any changes.
These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
Drag across the line below to select it, then copy it to the Clipboard by pressing the key combination command-C:
sudo pmset –a standbydelay
Don't copy the blank space at the end of the line.
Launch the Terminal application.
Paste into the Terminal window by pressing command-V. Press the space bar, then type the delay you want, in seconds. For example, if you want to change the standby delay from the default one hour to eight hours, enter 28800. Don't put commas or other punctuation marks in the number. To disable standby, enter 0 (zero.)
When the command is complete, press return. You'll be prompted for your login password. Nothing will be displayed when you type it. Type carefully and then press return. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. After running it, quit Terminal. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
To disable standby on AC power, enter this command:
sudo pmset autopoweroff 0
and to revert to the default state,
sudo pmset autopoweroff 1