The explanation here works on OS X versions prior to Mountain Lion. If you have Mountain Lion reboot by holding cmd+r instead of cmd+s to go into Recovery Mode and change your password using the Graphical User Interface.
This has happened to me twice since I started taking Time Machine backups. Something went horribly wrong, you want to restore from a Time Machine backup and after all those hours of waiting for everything to be transferred over you're presented with the login screen...
But you can't log in. You type your password 3 times to make sure it's right but it doesn't let you log in. Here's how to fix it:
- Reboot the Mac and hold down cmd+s -- This will boot into single user mode. Black screen, white text.
- Mount the hard drive as explained at the prompt. -- Most likely: mount -uw /
- Type: passwd [your user name] -- For example: passwd jeroen (jeroen is my username on the machine). If you don't know your username, type: ls /Users
This will list the usernames on your computer.
- Enter your password, and confirm it by entering it again. Notice you do not "see" what you type, this is normal.
- Type: exit
The machine will reboot and you'll be able to log in again. *phew*