Reset forgotten Mac password
How do I protect my Mac from someone else resetting the password and accessing my data? Of course the fact that that final way of resetting a password is possible also means that an unauthorized person would be able to access the data on your Mac if they got their hands on it. Unfortunately, once a person has got access to your Mac, you've usually lost control over it. There are some steps you can take to protect your data though. The best way to protect your data is to turn on FileVault encryption. This encrypts the contents of your Mac, and the Password Reset utility will not show until you unlock it with Disk Utility. When you set up FileVault you recieve a Recovery Key (which you should print out) and a password. If you lose both of these your data will be lost forever. You can turn FileVault on in System Preferences > Security & Privacy > FileVault.
https://www.macworld.co.uk/how-to/mac/what-do-if-forgotten-mac-password-3594395/ Apple includes a tool with macOS or Mac OS X (depending on which version you are using) to replace a Mac's password. This is the best option if you have completely forgotten your password. Follow these steps: Turn off your Mac (choose Apple > Shut Down). Press the power button while holding down Command-R. The Mac will boot into Recovery mode. When you see the load bar appear you can let go of the keys. It may take a few minutes to load. Select Disk Utility and press Continue. Choose Utilities > Terminal. Enter resetpassword (all one word, lowercase letters) and press Return Select the volume containing the account (normally this will be your Main hard drive). Choose the account to change with Select the User Account. Enter a new password and re-enter it into the password fields. Enter a new password hint related to the password. Click Save. A warning will appear that the password has changed, but not the Keychain Password. Click OK. Click Apple > Shut Down. Now start up the Mac. You can login using the new password.
http://www.maintain.se/blog/reset-forgotten-mac-password/ In the old days you could reset a login password via a Mac's OS X installer disc. But with no such discs, what to do? To reset a login password in OS X Mountain Lion or later, restart the Mac and hold down Command-R to boot into the Recovery HD partition. From the Utilities menu, choose Terminal to open it. In Terminal type: resetpassword and press Return. In macOS Sierra and macOS High Sierra, an Reset Password assistant will launch. Choose the user account or admin account you want to reset the password for. Enter a new password, confirm the new password, set (if you like) a password hint and then click on "Next" to set the new password for the account in question. Choose to "Restart" the Mac and when the Mac boots up, use the newly reset password to login to the computer. In OS X Mountain Lion, OS X Mavericks, OS X Yosemite and OS X El Capitan, a Reset Password window will appear that will list all the bootable volumes attached to your Mac. Select the volume that contains the account you want to reset and choose the user name that needs its password reset. Enter and verify a new passwords in the appropriate fields and, if you like, enter a password hint. Click Save and the new password is applied to the account.