This will clear the UniFi admin password and allow you to reset it.
To begin, you'll need to download an old version of MongoDB Compass on the machine running your UniFi controller. 1.26.1 seems to work and can be downloaded for Windows here. Once downloaded, extract the ZIP file and open MongoDBCompass.exe.
Now, make sure you exit out of your UniFi controller. We'll be accessing the database directly and you'll need to make sure it is shut down.
Now, open a command prompt and navigate to your UniFi install folder located at [USER]\Ubiquity UniFi\ on Windows. Navigate into the bin folder. Now, run the following command to start the database in a way we can access it: .\mongodb.exe --dbpath ../data/db/. If you're accessing it from another machine, add --bind_ip [ip] to it.
Open MongoDB Compass and connect to mongodb://localhost. Once logged in, expand ace on the sidebar and open admin. You should see records for all admin accounts. Find the one that you want to reset the password for.
Change the x_shadow field to $6$QMP8Qw72$eYh0V7j3hhaz4B1KR71R9bsahrXm7Rnrn7pD95YlwUjPUjUH61C8HuOMckJBofGc/0WpRVhDGhNDi2NGTREm01, then click Apply.
You can now disconnect and hit control+C in your command prompt to exit out of the server. Now, start up your UniFi controller.
You should now be able to log in with the password password. Proceed to reset it in settings.