If you cannot reset your Mac's login password, please try this:
Start up from macOS Recovery
- Press and release the power button to turn on your Mac.
- Immediately after releasing the power button, press and hold Command (⌘)-R.
- Keep holding the keys until you see an Apple logo or spinning globe.
- You might be asked to select a Wi-Fi network or attach a network cable. If you don't see a Wi-Fi menu, look for it in the upper-right corner of the screen.
Click “Forgot all passwords?”: If you're asked to select an admin user you know the password for, click “Forgot all passwords?” and proceed as described below.
Enter your Apple ID information. You might also be asked to enter the verification code sent to your other devices.
If you see an Activation Lock window, click Exit to Recovery Utilities. Then continue as described in the next section, “Use the Reset Password assistant.”
If you're asked to select a user that you want to reset the password for:
- Select the user, then enter your new password information and click Next.
- When authentication has succeeded, click Exit.
- Choose Apple menu > Restart. Password reset is now complete. You don't need to take additional steps.
You should now see the utilities window, which shows options such as restoring from Time Machine, reinstalling macOS, and using Disk Utility.
- From the Utilities menu in the menu bar, choose Terminal.
- In the Terminal window, type resetpassword, then press Return to open the Reset Password assistant.
- If you're asked to select an admin user you know the password for, click “Forgot all passwords?”.
- At the Reset Password window, click Deactivate Mac, then click Deactivate to confirm.
- If you see an Activation Lock window, enter your Apple ID email and password, then click Next.
- At the Reset Password window, enter your new password information, then click Next. (If this window shows multiple user accounts, click the Set Password button next to each account name, then enter the new password information for each account.)
- When the password reset is completed, click Exit.
- Choose Apple menu > Restart, then log in with your new password.
If you still can't reset your password, erase your Mac
If no other solution is successful, you can reset your password by erasing your Mac.
- Shut down your Mac, then start up from macOS recovery as described previously.
- When you're asked to select an admin user you know the password for, choose Erase Mac from the Recovery Assistant menu in the menu bar.
- From the Erase Mac window, click Erase Mac, then click Erase Mac to confirm.
- If your Mac restarts to a flashing question mark, press and hold the power button for a few seconds until your Mac turns off.
- Start up from macOS Recovery again, then reinstall macOS. For details, see How to reinstall macOS.
See this link for further reference
https://support.apple.com/102673