Gitlab忘记root密码

查询用户id


访问接口查询用户信息 http://gitlab_url/api/v4/users?username=root

返回

[{"id":1,"name":"Administrator","username":"root","state":"active"]

根据id查询用户信息并重置密码

#启动 gitlab-rails console
root@gitlab:/# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
 GitLab:       13.12.2-ee (865a93b831b) EE
 GitLab Shell: 13.18.0
 PostgreSQL:   12.6
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.6)
#查询用户
irb(main):001:0> user= User.find(1)
=> #
#设置密码
irb(main):002:0> user.password="admin!01"
=> "admin!01"
#确认密码
irb(main):003:0> user.password_confirmation="admin!01"
=> "admin!01"
#保存用户
irb(main):004:0> user.save!
Enqueued ActionMailer::MailDeliveryJob (Job ID: 49871208-26e2-418f-b62b-093397e5ecf6) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#>]}
=> true
#退出
irb(main):005:0> exit

参考链接


https://docs.gitlab.com/ee/security/reset_user_password.html

你可能感兴趣的:(git,后端,gitlab,密码,忘记,root)