Creating admin using rake admin:create

(Hammad Abbasi) #1


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.

Troubleshooting multi-site databases
(Régis Hanol) #2

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

RAILS_DB=site1 rake admin:create

(Hammad Abbasi) #3

It’s still creating admin account for first web site

(Hammad Abbasi) #4

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”

(Hammad Abbasi) #5


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 ?

(Alan Tan) #6

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

(Alan Tan) #7

Try RAILS_DB=b_discourse rake admin:create?

(Hammad Abbasi) #8

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

(Alan Tan) #9

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:

(Hammad Abbasi) #10

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

(Alan Tan) #11

Try RAILS_DB=secondsite instead.

(Hammad Abbasi) #12

Bingo - It worked :smiley:

Thanks alot

(Régis Hanol) #13