Creating admin using rake admin:create in multisite configuration

Hi,

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
4 Likes

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ā€

Hi,

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)

before_bundle_exec:
- file:
path: $home/config/multisite.yml
contents: |
secondsite:
adapter: postgresql
database: b_discourse
pool: 25
timeout: 5000
db_id: 2
host_names:
- community.mydomain.com

I just realized ā€œRAILS_DB=b_discourse rails consoleā€ is also connecting to first database

Try RAILS_DB=secondsite instead.

3 Likes

Bingo - It worked :smiley:

Thanks alot

1 Like