Creating admin using rake admin:create in multisite configuration


I am running discourse multi-site setup, I am wondering how can i create administrator using
rake admin:create

It creates the administrator on first site.

You have to switch database using the RAILS_DB=<name_of_db> prefix before the command

RAILS_DB=site1 rake admin:create

It’s still creating admin account for first web site

I am also trying to connect to 2nd database manually using

su -c ‘psql discourse’ postgres

but it throws error “no password entry for user postgres”


I have setup a multi-site up and running however I am unable to create admin or configure notification email for 2nd site
so i have few questions

How can i configure SiteSettings in app.yml for a) 2nd Site b) ALL SITES

  • exec: rails r “SiteSetting.notification_email=’’”

I have tried manually connecting to both databases using
sudo -u postgres psql b_discourse
but when i run select * from users ( it returns nothing )

I tried running “rake admin:create RAILS_DB=b_discourse”- but this is creating the user on first site.

I ran “SiteSetting.notification_email” command in rails console it shows email from 1st Site - is there any way i can switch database in rails console ?

RAILS_DB=b_discourse rails console or RAILS_DB=b_discourse rails runner <command>

Try RAILS_DB=b_discourse rake admin:create?

I did but didn’t work (creating on first site)

I am however able to use 2nd db using "RAILS_DB=b_discourse rails console "
Can i create an admin user or change password of existing user using this console ?

Please advice. Many Thanks for your Help

Hmm I’m not sure why it isn’t working for you. I just tested locally and it works fine.

Yup you can :slight_smile:

Below is my app.yml for 2nd site ( First site is using default - discourse_hostname)

- file:
path: $home/config/multisite.yml
contents: |
adapter: postgresql
database: b_discourse
pool: 25
timeout: 5000
db_id: 2

I just realized “RAILS_DB=b_discourse rails console” is also connecting to first database

Try RAILS_DB=secondsite instead.


Bingo - It worked :smiley:

Thanks alot

1 Like