keycloak

Keycloak lost admin password


I have a local test installation of keycloak 12 and unfortunately I've lost the admin password, any idea on how to reset it or reset the keycloak configuration without losing the realms ?

I already used add-user cli command to add a user but even with that one I can't access


Solution

    1. Run h2database console:
    java -cp ./modules/system/layers/base/com/h2database/h2/main/h2-1.4.197.jar org.h2.tools.Console -url "jdbc:h2:./standalone/data/keycloak;AUTO_SERVER=TRUE" -user sa -password sa
    
        delete from credential where user_id = '<user-id>';
        delete from user_role_mapping where user_id = '<user-id>';
        delete from user_entity where id = '<user-id>';
    
    1. Run add-user
    1. Run keycloak
    2. start localhost:8080/auth/