Traditionally, it’s been possible to boot into recovery mode and select Utilities > Password Reset from the menu, which you could use to reset a password if you’ve forgotten it. This option was removed back in OS X Lion, but you can still access the same password-reset utility in recovery mode by selecting Utilities > Terminal, typing resetpassword into the terminal window, and pressing Enter. Recovery Mode doesn’t normally require a password to access, even though you’d need to enter your password when booting your Mac normally. The key to this process is Recovery Mode - a special environment anyone can access on your Mac if they reboot it and hold Command+R as it boots up.
RELATED: How to Bypass and Reset the Password on Every Operating System