Mac login password being forgotten by Mac Mini

I have a 2018 Mac Mini. It works fine when switched on and I’m pleased with it. However if I leave the computer switched off for a few days, it seems to “forget” my login passwords. It isn’t a major problem as I have got quite used to using password recovery as I know my password, but it is a nuisance. In old old days, computers used to have a small battery that prevented this type of thing but I know that technology has now moved on. Any ideas how I prevent it from “forgetting” my login details please? Thanks

Are you an Admin on your account, and if so, do you have Automatic Login set in System Preferences > Users and Groups?

If so, you could try resetting it by choosing ‘Off’, closing System Preferences, going back and selecting your account, and then restarting. (Or turning it off, restarting, logging in, and turning it back on.)