So you want to create/grant Admin privileges or reset user password from console? Great, let’s get started!
Access Console
Connect to your Droplet via SSH, or use Putty on Windows:
ssh root@192.168.1.1
Replace 192.168.1.1
with the IP address of your Droplet.
Switch to your Discourse folder:
cd /var/discourse
Enter the container:
./launcher enter app
Create New Account with Admin Privileges
Run this command from console:
rake admin:create
instructions for multisite
If you have a multisite configuration you’ll do
RAILS_DB=my_site_db rake admin:create
You will be asked for Email, Password and Confirm Password.
After providing required information a new account will be created with random username (based on email address).
Now you will be asked: Do you want to grant Admin privileges to this account? (Y/n)
. Press enter to continue.
If it worked, you’ll see Your account now has Admin privileges!.
Reset Password for Existing Account
Run this command from console:
rake admin:create
You will be asked for Email, enter the email of an existing account.
Now you will be asked: User with this email already exists! Do you want to reset the password for this email? (Y/n)
. Press enter to continue.
Provide the new password
and confirm password
.
If it worked, you’ll see Account updated successfully!.
Grant Admin Privileges to Existing Account
Run this command from console:
rake admin:create
You will be asked for Email, enter the email of existing account.
Now you will be asked: User with this email already exists! Do you want to reset the password for this email? (Y/n)
. Press n then enter.
Now you will be asked: Do you want to grant Admin privileges to this account? (Y/n)
. Press enter to continue.
If it worked, you’ll see Your account now has Admin privileges!.
Instructions for multisite
Follow the instructions above, except include RAILS_DB=multisite_name
before the command. multisite_name
is the top line of a multisite stanza (not the name of the actual database!). So, if your site looks like this:
mysite:
adapter: postgresql
database: database2
password: secret
pool: 25
host: data
host_names:
- mysite.example.com
You would
RAILS_DB=mysite rake admin:create
Penultimate Review by @SaraDev on 2022-05-26T00:00:00Z
Last Reviewed by @pfaffman on 2022-12-13T00:36:00Z