gitlab重置root的密码

gitlab管理员帐号可以给普通用户创建账户,分配权限,拥有所有项目和组的权限,普通用户新建完成之后,需要管理员给分配合适的权限,才能正常的使用。如果管理员账户的密码忘记了,一般可以通过邮箱找回,但如果当初的管理账户设置的邮箱不可使用了,其实还可以强制重置的方式来找回密码的,下面就来介绍下如何强制找回

解决:
gitlab-ctl start 保证gitlab处于启动状态,&保证redis处于启动状态
gitlab-rails console production 进入gitlab串口环境下
irb(main):001:0>user = User.where(id: 1).first 定位到gitlab 数据库中Users表中的一个用户,通常就是管理员用户admin@local.host
irb(main):002:0> user.password=12345678   重置管理员密码为12345678
irb(main):003:0> user.password_confirmation=12345678   确认管理员密码为12345678
irb(main):004:0> user.save!    保存更改信息

# su - git
-sh-4.2$ gitlab-rails console production
-------------------------------------------------------------------------------------
 GitLab:       12.0.3 (08a51a9db93)
 GitLab Shell: 9.3.0
 PostgreSQL:   10.7
-------------------------------------------------------------------------------------
Loading production environment (Rails 5.1.7)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):004:0> user.password=12345678
=> 12345678
irb(main):005:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 60439440-6443-46d1-acda-e29172be146a) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007f09e949b958 @uri=#<URI::GID gid://gitlab/User/1>>
=> true
irb(main):006:0> exit
-sh-4.2$ exit
[root@qas-k8s-gitlab gitlab]# gitlab-ctl restart
ok: run: alertmanager: (pid 43507) 0s
ok: run: gitaly: (pid 43523) 0s
ok: run: gitlab-monitor: (pid 43542) 1s
ok: run: gitlab-workhorse: (pid 43550) 0s
ok: run: grafana: (pid 43563) 1s
ok: run: logrotate: (pid 43576) 0s
ok: run: nginx: (pid 43659) 1s
ok: run: node-exporter: (pid 43665) 0s
ok: run: postgres-exporter: (pid 43671) 0s
ok: run: postgresql: (pid 43680) 1s
ok: run: prometheus: (pid 43690) 0s
ok: run: redis: (pid 43701) 1s
ok: run: redis-exporter: (pid 43705) 0s
ok: run: sidekiq: (pid 43715) 0s
ok: run: unicorn: (pid 43726) 1s
上一篇:Oracle中查询表的大小、表的占用情况和表空间的大小


下一篇:PAT Advanced 1044 Shopping in Mars (25) [⼆分查找]