Change your password
If you know your password and can use it to log in to your account, you can change your password in Users & Groups preferences:
1. Choose System Preferences from the Apple menu, then click Users & Groups.
2. Select your user name from the list of users.
3. Click the Change Password button, then follow the onscreen instructions. If you're using a password hint, remember to update the hint for your new password.
Reset your password
If you don't remember your password, or it isn't working, you might be able to reset it using one of the methods described below. But first try these simpler solutions:
1. Make sure that you're typing the correct uppercase or lowercase characters. If your keyboard has Caps Lock turned on, the password field shows a Caps Lock symbol Upward-pointing arrow.
2. If the password field shows a question mark, click it to display a password hint that might help you to remember.
3. Try to log in without a password. If that works, you can then add a password by following the steps to change your password (as described above).
4. Try to log in with the Apple ID password that you use for iCloud. If you just changed that password and the new password isn't working, try the old password first. If that works, you should be able to use the new password from then on.
Reset using another admin account
If you know the name and password of an admin account on your Mac, you can use that account to reset the password.
1. Log in with the name and password of the other admin account.
2. Choose System Preferences from the Apple menu, then click Users & Groups.
3. Click the Lock button closed lock, then enter the admin name and password again.
4. Select your user name from the list of users.
5. Click the Reset Password button, then follow the onscreen instructions to create a new password:
6. Choose Log Out from the Apple menu.
7. Log in to your account using your new password.
8. Create a new login keychain.
Credit: https://support.apple.com/en-in/HT202860