How to change your username and/or password from the Terminal
1. Boot into Single-user Mode .
2. At the prompt enter the following commands. Press RETURN after each:
mount -uw /
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
dscl . -passwd /Users/username password
Replace username with the targeted user and password with the desired password.
This allows you to reset the password in single user mode without booting from the install media. The above tip is attributed to Satcomer.