OS X used to be sold on a CD and if you needed to change the admin password, the easiest way to do so was to use the disc to create a new one. If you have the Mac OS X installation disc for Lion (OS X 10.7) or Mountain Lion (10.8), or know an administrator password and you just want to change it, you can follow the instructions provided on Apple’s website.
However, that won’t mean anything to you if don’t have the installation CD, or don’t remember the password. Plus, nowadays OS X can be downloaded and there are no discs provided. Fortunately, there are different solutions that will help you to reset the administrator password, even if you don’t have a disc. Just make sure that before you try these options, you backup all your files to avoid data loss.
This is a simple option, but it would only work in certain cases. When you first set up your Mac or upgrade the OS, the Setup assistant asks you if you want to allow your Apple ID to reset the admin password. If this option is enabled, you would see it marked in Users & Groups, within System Preferences. Bear in mind that if the box is not selected and you have forgotten your password, this will not work. However, many users prefer not to rely on this method for security reasons. If Apple’s system is compromised, your admin password could be at risk too, which is why you may prefer to try other solutions.
User another administrator account
Since an administrator can reset the password of another one, this may work if you originally set up the Mac with two administrator accounts. You can use one administrator account to reset the password of the one whose password you have forgotten.
Single User Mode
This is another alternative that will enable you to reset the admin password. Single User mode is a limited environment, but it allows you to perform advanced troubleshooting. When you boot into single user mode, you will be able to set up a new admin account. Here is what you need to do:
1. Reboot the Mac and hold down Command + s to enter single user mode. Keep Command + s pressed until a black screen with white text appears. At the right bottom of the screen, you will see a square. That is the command prompt.
2. Type mount-uw / at the command prompt. This will mount the root file system and commands the computer to change the status of any files systems that are already mounted, while ensuring that it’s read-write. To move to the next line, press enter and then type: rm/var/db/.AppleSetupDone This command removes the Apple Setup, which tricks the Mac into thinking that it is a new computer. In other words, deleting the Apple Setup file will return the Mac to its original state
3. After entering rm/var/db/.AppleSetupDone press enter to go to next line and then enter this: shutdown -h now. This will prompt the Mac to shutdown immediately. After the command has been executed, press the power button to turn the Mac on. You should see a message welcoming you to Mac OS X and the setup screen will guide you through the process to create a new admin account.
If the above options don’t work for you, you can try the OS X Recovery Partition. This option is available for OS X 10.7 (Lion), 10.8 (Mountain Lion), OS X 10.9 (Mavericks) and OS X 10.10 (Yosemite) and it only takes a few steps.
1. Restart your Mac, press Command + r and hold for a few seconds, release them and you should see the Apple logo and spinning gear, or progress bar if you are using Yosemite.
2. Mac will boot into OS X on the Recovery Partition, which was created when you installed the OS X.
3. After booting, you will see a “OS X Utilities” window. In the Utilities Menu, select Terminal and type: resetpassword and hit return.
4. You will see a new window. There you can click on the volume that contains the user account, select the relevant user account name in the dropdown menu below, then enter your new password two times and click Save.
5. Go to Apple Menu at the top. Select OS X Utilities, then Quit OS X Utilities. This will restart the Mac. Once the Mac restarts, you should be able to log into the admin account using the new password you created.