If you have Apple Silicon, power off, and then power back on, but continue holding the power button until boot Options load.
Select Options > Utilities > Terminal
Type resetpassword > hit return key
If you see Forgot all passwords. Click that.
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.
When the password reset is completed, click Exit.
Choose Apple menu > Restart, then log in with your new password.