I’ve been testing a local installation of keycloak a long time ago. Now that I want to login back into the admin console I’m unable to do so. It looks like I forgot the username/password.
Is there a way for me to reset the admin/password to a default one, by using for example the CLI or some tool running on the server?
Long shot here and please only use at your own risk:
You mention “local installation” and “a long time ago” so am assuming it’s the Wildfly version using the built-in H2 database.
If you run the following within your keycloak directory, you can access the H2 database directly:
java -cp ./modules/system/layers/base/com/h2database/h2/main/h2-*.jar org.h2.tools.Console -url "jdbc:h2:./standalone/data/keycloak;AUTO_SERVER=TRUE" -user sa -password sa
You can then delete the admin user from the USER_ENTITY table but first you will need to delete the foreign keys from the CREDENTIAL and USER_ROLE_MAPPING tables. Once the admin user is deleted, you should be provided with the “create a new admin user” form when you access the admin panel.
This all said, maybe simpler just to reinstall fresh & am sure there must be an easier way to do this than messing with DB internals.