跳到主要内容

gitlab忘记root密码

[toc]

1.切换到 git 用户

su - git

2.登录gitLab的rails控制台

$ gitlab-rails console
--------------------------------------------------------------------------------
GitLab: 12.10.1 (e658772bd63) FOSS
GitLab Shell: 12.2.0
PostgreSQL: 11.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.2)
irb(main):001:0>

3.执行命令定位到root用户 user = User.where(id: 1).first

irb(main):003:0> user = User.where(id: 1).first
=> #<User id:1 @root>

4.修改root密码 user.password='xxx'

irb(main):004:0> user.password='xxx'
=> "xxx"

5.保存密码 user.save!

irb(main):005:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 20ec0a5f-9762-473a-9db6-b2eb14b091c1) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007f47ec470460 @uri=#<URI::GID gid://gitlab/User/1>>
=> true

保存密码重新使用root用户登陆即可

Right Bottom Gif
Right Top GIF