What is the Rails command to create an admin user in Discourse?

סיכום מבוסס בינה מלאכותית

To create an admin user in Discourse without email activation, use the command rake admin:create. This command will prompt for the admin’s username and password.

To run this command, first enter the Discourse app using ./launcher enter app, then run rake admin:create. As noted by DBHacker, you can also view a list of available rake tasks using rake --tasks.

Bathinda attempted to use a different method through the Rails console, but encountered errors. Stephen and DBHacker provided the correct solution, which Bathinda successfully implemented.

As told in this post, when I run this command to create an admin user on a new disco installation, thru rails console (without having to activate thru email, for just once, for one admin):

u = User.create!(username: ‘xx’, email: ‘xx@xx.com’, password: ‘xxx’, mailing_list_mode: ‘true’);u.approve(Discourse.system_user, false) ; u.activate

I get this error:

[1] pry(main)> =“u = User.create!(username: 'user1’, email: ‘user1@email.com’, password: ‘Password12345’, mailing_list_mode: ‘true’);u.approve(Discourse.system_user, false) ; u.activate"

SyntaxError: unexpected '=', expecting end-of-input
=“u = User.create!(username:...
^

I’m no user of rails commands, I could appreciate if you could tell the exact command with exact quotes etc I’ve to use in the command in order to just create 1 admin user on a fresh Disco installation.

Take your pick:

rake admin:create                                                      # Creates a forum administrator
rake admin:invite[email]                                               # invite an admin to this discourse instance

FYI, when you are not sure, you can always:

rake --tasks

To get a list of rakes.

Thanks.
But email sending is not working, that’s why I said I want to use it only once, just to create one admin user.

rake admin:create that’ll help you create admin

But in this command, we’ve not specified any username or password.
how will we login thereafter?

Sorry, as I said, I don’t know a thing about rails commands. Just want to this one ‘needed’ command.

[6] pry(main)> rake admin:create                                                      # Creates a forum administrator
NameError: undefined local variable or method `create' for main:Object
from (pry):5:in `__pry__'

That is why I posted two choices.

You can pick based on your situation now and in the future.

Run the command and it will ask you.

[6] pry(main)> rake admin:create                                                      # Creates a forum administrator
NameError: undefined local variable or method `create' for main:Object
from (pry):5:in `__pry__'

It isn’t entered in the rails console.

Use:

./launcher enter app
rake admin:create

Oh! my my!!

Thanks.

Did it, and all ok now.