Reset admin account without email

Hello !

I use metabase with docker. My container was stopped and to use metabase I need to login.
Unfortunately, I forgot my credentials. I saw that we can reset password with this command:
java -jar metabase.jar reset-password email@email.com

But I forgot the email used to create the admin account.
Is there a way to find the admin email to reset the password?

Thanks,
Aimen

Hi @aimen
You would need to access the application database table core_user to see the emails.
If you are using H2, then migrate away from that:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html

Hi @flamber, thanks for the answer. This will be my last option. But can we edit the H2 directly inside the docker container ?

@aimen The H2 default location on Docker is /metabase.db/metabase.db.mv.db - you can use DBeaver.io or similar to edit that.

Thank you @flamber :smile:

I used the tool provided by H2:

It's a simple way to find the email and reset the password (with the reset-password provided by metabase).

Thank!

I got the email from the h2 admin panel, but when running java -jar metabase.jar reset-password my@email.com I'm getting a "check your spelling" error. I've double-checked and tried different emails from the user tables:

/app # java -jar metabase.jar reset-password my@email.com
Warning: environ value jdk-11.0.10+9 for key :java-version has been overwritten with 11.0.10
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
2021-04-29 00:18:30,346 INFO metabase.util :: Maximum memory available to JVM: 498.0 MB
2021-04-29 00:18:39,370 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance. ๐Ÿ”“ 
 For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
2021-04-29 00:18:45,909 INFO metabase.core :: 
Metabase v0.38.4 (057b6bb release-x.38.x) 

Copyright ยฉ 2021 Metabase, Inc. 

Metabase Enterprise Edition extensions are NOT PRESENT.
2021-04-29 00:18:45,922 WARN metabase.core :: WARNING: You have enabled namespace tracing, which could log sensitive information like db passwords.
2021-04-29 00:18:45,938 WARN db.env :: WARNING: Using Metabase with an H2 application database is not recommended for production deployments. For production deployments, we highly recommend using Postgres, MySQL, or MariaDB instead. If you decide to continue to use H2, please be sure to back up the database file regularly. For more information, see https://metabase.com/docs/latest/operations-guide/migrating-from-h2.html
2021-04-29 00:18:45,942 INFO db.setup :: Verifying h2 Database Connection ...
2021-04-29 00:18:46,191 INFO db.setup :: Successfully verified H2 1.4.197 (2018-03-18) application database connection. โœ…
2021-04-29 00:18:46,191 INFO db.setup :: Running Database Migrations...
2021-04-29 00:18:46,194 INFO db.setup :: Setting up Liquibase...
2021-04-29 00:18:46,226 INFO db.setup :: Liquibase is ready.
2021-04-29 00:18:46,226 INFO db.liquibase :: Checking if Database has unrun migrations...
2021-04-29 00:18:47,494 INFO db.setup :: Database Migrations Current ...  โœ…
2021-04-29 00:18:47,516 INFO db.data-migrations :: Running all necessary data migrations, this may take a minute.
2021-04-29 00:18:47,527 INFO db.data-migrations :: Finished running data migrations.
Database setup took 1.6 s
Resetting password for my@email.com...

FAIL [[[No user found with email address 'my@email.com'. Please check the spelling and try again.]]]

@Raschid Well, you should migrate away from H2:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html
And emails are case sensitive, and only works for non-deactivated users.

@flamber So reset-password is not working on H2, is this correct? Because I can see my email in H2 CORE_USER table, but with reset-password I get the same 'No user found...' exception.

@tonyskulk It is working for any application database, but you should not be using H2 if you're running Metabase in production.

And it is case-sensitive, so it has to match what is in core_user. And only works for non-deactivated users.

@flamber Thanks for your quick reply. I am aware that I should switch to postgres at some point in time. For me the question is if this switch will solve my restting password problem. If I understand your response correctly, this should not be the case and it can be solved using H2, too.

So, some more informations what I did:
I am using the newest official metabase/metabase docker image and haven't changed the database yet. I copied the h2 db file and viewed it locally, so I can see that the CORE_USER table contains only one user - the user I want to reset the password for. As far as I can see, the user is not deactivated (IS_ACTIVE and IS_SUPERUSER columns are both set to true).
I copied the EMAIL value directly from the db, so it took the value as is without changing the case (it is completely in lower case btw), but I still got the 'No user found...' error when trying to run this command inside the docker container's / directory:

java -XX:+IgnoreUnrecognizedVMOptions -Dfile.encoding=UTF-8 -Dlogfile.path=target/log -XX:+CrashOnOutOfMemoryError -server -jar /app/metabase.jar reset-password my.double.checked@mail.address

output:

bash-5.1# java -XX:+IgnoreUnrecognizedVMOptions -Dfile.encoding=UTF-8 -Dlogfile.path=target/log -XX:+CrashOnOutOfMemoryError -server -jar /app/metabase.jar reset-password my.double.checked@mail.address
Warning: environ value jdk-11.0.14+9 for key :java-version has been overwritten with 11.0.14
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
2022-03-04 03:17:51,380 INFO metabase.util :: Maximum memory available to JVM: 1.9 GB
2022-03-04 03:18:04,388 INFO util.encryption :: Saved credentials encryption is DISABLED for this Metabase instance. ๐Ÿ”“
 For more information, see https://metabase.com/docs/latest/operations-guide/encrypting-database-details-at-rest.html
2022-03-04 03:18:08,179 INFO driver.impl :: Registered abstract driver :sql  ๐Ÿšš
 โฎฆ Load driver :sql took 676.5 ms
2022-03-04 03:18:08,202 INFO driver.impl :: Registered abstract driver :sql-jdbc (parents: [:sql]) ๐Ÿšš
Load driver :sql-jdbc took 704.9 ms
2022-03-04 03:18:08,208 INFO driver.impl :: Registered driver :h2 (parents: [:sql-jdbc]) ๐Ÿšš
2022-03-04 03:18:08,234 INFO driver.impl :: Registered driver :mysql (parents: [:sql-jdbc]) ๐Ÿšš
2022-03-04 03:18:08,257 INFO driver.impl :: Registered driver :postgres (parents: [:sql-jdbc]) ๐Ÿšš
2022-03-04 03:18:11,339 INFO metabase.core ::
Metabase v0.42.0 (de1264e release-x.42.x)

Copyright ยฉ 2022 Metabase, Inc.

Metabase Enterprise Edition extensions are NOT PRESENT.
2022-03-04 03:18:11,364 WARN db.env :: WARNING: Using Metabase with an H2 application database is not recommended for production deployments. For production deployments, we highly recommend using Postgres, MySQL, or MariaDB instead. If you decide to continue to use H2, please be sure to back up the database file regularly. For more information, see https://metabase.com/docs/latest/operations-guide/migrating-from-h2.html
2022-03-04 03:18:11,368 INFO db.setup :: Verifying h2 Database Connection ...
2022-03-04 03:18:11,743 INFO db.setup :: Successfully verified H2 1.4.197 (2018-03-18) application database connection. โœ…
2022-03-04 03:18:11,744 INFO db.setup :: Running Database Migrations...
2022-03-04 03:18:11,751 INFO db.setup :: Setting up Liquibase...
2022-03-04 03:18:11,821 INFO db.setup :: Liquibase is ready.
2022-03-04 03:18:11,822 INFO db.liquibase :: Checking if Database has unrun migrations...
2022-03-04 03:18:15,141 INFO db.setup :: Database Migrations Current ...  โœ…
2022-03-04 03:18:15,164 INFO db.data-migrations :: Running all necessary data migrations, this may take a minute.
2022-03-04 03:18:15,176 INFO db.data-migrations :: Finished running data migrations.
Database setup took 3.8 s
Resetting password for my.double.checked@mail.address...

FAIL [[[No user found with email address 'my.double.checked@mail.address'. Please check the spelling and try again.]]]

Any ideas what I did wrong?

@tonyskulk You are not referencing your H2 file. Please just migrate to Postgres, then everything will work.

Migrated to postgres and now I donยดt even have to reset the password as the previous password is working again. Strange, but ok for me.
Thanks!

@tonyskulk Yes, because you were not starting with the correct application database previously.