There are a few different methods you can use, and the road you take to unlock your Mac without a password could depend on whether you linked your Apple ID to your user account on your Mac during setup, or if you have one of the new M1 Macs. Because of that, MacOS includes a tool for this exact scenario. Apple knows that a forgotten password can be a personal hell, especially if you're working on a deadline. But what happens when you forget the password to log into your Mac? After trying, then retrying the password you thought was correct, it's only natural to want to panic. For online accounts, you can just click a few links, enter your email address and then reset your password.
I think it's safe to say we've all forgotten a password at some point.