Create an admin account from the console

:bookmark: This guide provides instructions for creating an admin account or granting admin privileges using the console in a self-hosted Discourse installation.

:person_raising_hand: Required user level: System Administrator
:warning: Console access required

So you want to create/grant Admin privileges or reset user password from console? Great, let’s get started!

This guide will cover the following:

  • Accessing the console
  • Creating a new account with admin privileges
  • Resetting an existing password
  • Granting admin privileges to an existing account
  • Multisite configuration instructions

Accessing the console

Connect to your Discourse server using SSH, or use Putty if you’re on Windows:

ssh root@your.server.ip

Replace your.server.ip with the actual IP address of your server.

Switch to your Discourse directory:

cd /var/discourse

Enter the Docker container:

./launcher enter app

Creating a new account with admin privileges

Inside the console, run the following command:

rake admin:create

You will be prompted for:

  • Email
  • Password
  • Confirm Password

A new account will be created with a username based on the email address. When asked if you want to grant admin privileges, press Enter to confirm.

If successful, you’ll see: “Your account now has Admin privileges!”

Instructions for multisite

If you have a multisite configuration you’ll run:

RAILS_DB=my_site_db rake admin:create 

Resetting the password for an existing account

To reset a password, execute the same command:

rake admin:create

Enter the email of the existing account. If the user exists, you will be asked if you want to reset the password. Press Enter to proceed. Provide and confirm the new password.

If it worked, you’ll see Account updated successfully!.

Granting admin privileges to an 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!.

Multisite configuration instructions

For multisite setups, prepend the commands with RAILS_DB=multisite_name, where multisite_name corresponds to the top line of your multisite configuration:

Example configuration:

mysite:
  adapter: postgresql
  database: database2
  password: secret
  pool: 25
  host: data
  host_names:
    - mysite.example.com

Command:

RAILS_DB=mysite rake admin:create
59 Likes
SOLVED: Unable to Grant Admin or Grant Moderator to existing users
System account login
How to install Discourse on windows
Troubleshoot email on a new Discourse install
How to access the discourse database?
Run Discourse without email?
Cannot access /admin
How to install Discourse without a mail server?
Dummy user to create initial content
Not getting activation email
Remove the installation step Resend Activation Email discourse
Why is email verification required upfront?
Blank login and signup page
Reset lost admin password
I can't change my admin user email
FAQs on recurring topics
Getting stuck during bootstrap
Grant administrator rights to a user
Send admin account email to different email
Grant admin confirmation mail not sent
How to resend activate email when I close the tab
Developing Discourse Plugins - Part 1 - Create a basic plugin
Sidekiq shows activation emails being sent to email address nil
Emails to confirm new admin not being sent
Set up Discourse for development on Fedora Linux
Trying to install Discourse on Docker before server just testing software?
Installing Discourse using Portainer
Developing Discourse using a Dev Container
Install Discourse on Ubuntu or Debian for Development
Can Discourse function without emails entirely?
Install Discourse for development using Docker
Update our admins and moderator shields
Discourse as Your First Rails App
Skipped Email - User does not exist
Require mail confirmation to grant admin privileges
Connecting to Droplet
So I can't login anymore :( and won't receive email logins or forgotten password emails
Generating mailing logs for console to check installation?
Adding a User Without Inviting Them
Admin confirmation link broken
Problème de réception du mail de confirmation admin (installation sur Hostinger)

im on a codespace i clicked the :globe_with_meridians: on 4200 and it says no admin account how do I do this on the git hub code space