Forgot password on Self-hosted Ghost?
How to reset your Ghost password by modifying the database record for your user. (Yes I didn't setup email)
I self-host Ghost (self-ghost haha) on my server. I like learning the nitty gritty of the software I use, and having the freedom to modify it as required.
Steps
Finding the Database container
$ docker ps | grep ghost
ab1e09b2054d mysql:8.0 ...
a32af31513c6 ghost:5-alpine ...
We're interested in the database container, that's mysql
. Let's copy the container's ID for the time being (ab1e09b2054d
).
Connecting to the Container
$ docker exec -it ab1e09b2054d/bin/sh
Connects to the container and runs the shell.
mysql CLI
To modify the database, we'll need to use the mysql CLI.
$ mysql -u <username> -p<password> <database_name>
For me, the command was: $ mysql -u root -p<password> ghost
Modifying the Data
We're in the database, we'll need the email address registered with ghost.
Execute
SELECT * from users;
, and copy your email address from the output.With this in hand, we can modify our password.
Head to https://bcrypt-generator.com and paste in your new password. Hit encrypt, and copy the output on the right.
With the password hash copied, run the following:
UPDATE users SET password='<password_hash_here>' WHERE email='<email_address>';
And that's it! We've regained access.
Thanks to Tekspace.io's post on the same.