# 通过控制台激活管理员账户

**URL:** https://meta.discourse.org/t/activating-admin-account-from-console/79146
**Category:** Self-hosting
**Created:** [2018年一月27日 09:46 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146 "2018-01-27T09:46:20Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![gpritiranjan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gpritiranjan/32/88408_2.png) [@gpritiranjan](https://meta.discourse.org/u/gpritiranjan)
#### Post date: [2018年一月27日 09:46 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/1 "2018-01-27T09:46:20Z")

</div>

I am trying to setup Discourse with one-click installer using droplet over Digital Ocean. I followed all the instructions and have correctly configured the SMTP details. But when I register for the admin account using the front-end installer, I am not able to receive the email.

I read a tutorial where it is mentioned that if the email doesn’t land in the mailbox, I can still activate the account and set the user as admin using the following commands using the console:

```
cd /var/discourse
sudo ./launcher enter app
rails c
user = User.find_by_email("<admin_email>")
user.admin = true
user.approved = true
user.save
EmailToken.confirm(user.email_tokens.first.token)

```

I am able to run the commands up to the fourth line. After running the fourth command, it finds and displays the user details. But I am not able to enter the next command. There’s this colon “:” and when I reach the end of the displayed details, “(END)” is written. I can’t type and run the further commands to activate the user.

After rails c, there’s this [1] pry (main) \> thing. I am not so much acquainted with the command line. Please help me out.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [2018年一月27日 10:55 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/2 "2018-01-27T10:55:56Z")

</div>

When the colon appears, press `q` to get back to a prompt, and type the next command.

---

<div class="post-metadata">

### Author: ![gpritiranjan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gpritiranjan/32/88408_2.png) [@gpritiranjan](https://meta.discourse.org/u/gpritiranjan)
#### Post date: [2018年一月27日 11:31 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/3 "2018-01-27T11:31:49Z")

</div>

Thanks. It resolved the issue.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2018年一月27日 13:47 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/4 "2018-01-27T13:47:37Z")

</div>

If you’re not receiving mail, then mail is not correctly configured.

You seem to have solved your account creation problem, but the recommended way to create an admin account and password is

. /launcher enter app  
rails c  
rake admin:create

That will allow you to

- create an account
- change an account password
- assign admin to an account

---

<div class="post-metadata">

### Author: ![deltamotion](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@deltamotion](https://meta.discourse.org/u/deltamotion)
#### Post date: [2019年三月26日 19:20 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/5 "2019-03-26T19:20:58Z")

</div>

This worked great! Note that the `rails c` is not necessary for running the rake commands.

> [@pfaffman](#):
>
> . /launcher enter app  
> rake admin:create

---

<div class="post-metadata">

### Author: ![fishfree](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fishfree/32/235911_2.png) [@fishfree](https://meta.discourse.org/u/fishfree)
#### Post date: [2023年四月18日 05:44 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/6 "2023-04-18T05:44:38Z")

</div>

根据您最新版本帖子中的说明，我无法激活管理员帐户。在最后一条命令处发生错误：

 ![image](https://global.discourse-cdn.com/meta/original/4X/2/f/0/2f0eaabcde10a956e1b6eb0d4cfa47374116ce9a.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2023年四月18日 06:03 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/7 "2023-04-18T06:03:33Z")

</div>

通过控制台创建管理员的当前方法是：

```plaintext
./launcher enter app
rake admin:create

```

---

<div class="post-metadata">

### Author: ![fishfree](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fishfree/32/235911_2.png) [@fishfree](https://meta.discourse.org/u/fishfree)
#### Post date: [2023年四月18日 06:06 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/8 "2023-04-18T06:06:25Z")

</div>

我在这里找到了解决方案：[Discourse Admin Quick Start Guide](https://www.phylobabble.org/t/discourse-admin-quick-start-guide/3/)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2024年六月8日 12:36 UTC](https://meta.discourse.org/t/activating-admin-account-from-console/79146/9 "2024-06-08T12:36:43Z")

</div>

此主题已在 2324 天后自动关闭。不再允许回复。
