Locked out of your own Portainer? Do not reinstall it, there is a small helper image for this.
Stop the Portainer container, run the helper against the same data volume, and start Portainer again:
docker stop portainer
docker run --rm -v portainer_data:/data portainer/helper-reset-password
docker start portainer
The helper prints a new random password. Copy it right away, because it is only shown once. If you would rather choose your own, add --password "yourpassword" to the helper command. Portainer hashes it before storing it.
Two caveats. The container must be stopped first. And the volume name in the command has to match yours: portainer_data is the default in the docs, but a bind mount or a different name needs changing. If there is no admin user at all, the helper creates one, and if the name admin is taken, you get admin- plus random characters.
If you want the password to be fixed instead of random, the helper also accepts --password-hash with a bcrypt hash, but you cannot combine it with --password. For a home setup the random one is fine. Put the result in a password manager. After you log in, change it under your user settings if you want something you can remember.
Further reading: Reset the admin password, On this site: start Portainer with –admin-password-file instead of typing the password in time, On this site: add Docker Hub to Portainer's registries with an access token, not your password