9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GitLabのrootパスワード変更方法

Posted at

概要

GitLabのrootパスワードを忘れてしまった場合に、パスワードを変更する方法

手順

Gitlabサーバにログインし、RilsConsoleを起動する。

$ sudo gitlab-rails console -e production
--------------------------------------------------------------------------------
 GitLab:       12.4.0 (1425a56c75b)
 GitLab Shell: 10.2.0
 PostgreSQL:   10.9
--------------------------------------------------------------------------------
Loading production environment (Rails 5.2.3)

ユーザID(rootは1)からユーザを取得する。

irb(main):001:0> user = User.find(1)
=> #<User id:1 @root>

パスワードを設定する。

irb(main):007:0> user.password = 'password'
=> "password"
irb(main):008:0> user.password_confirmation='password'
=> "password"

保存する。

irb(main):011:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: d21626c7-04f4-4068-80c0-e9fa1d1ffdfd) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007fbc78357c58 @uri=#<URI::GID gid://gitlab/User/1>>
=> true

GitLabにアクセスすると、上記で設定したパスワードでログインできるようになっている。

参考

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?