侧边栏壁纸
博主头像
WinJay博主等级

博观而约取 厚积而薄发

  • 累计撰写 319 篇文章
  • 累计创建 169 个标签
  • 累计收到 1 条评论
隐藏侧边栏

Gitlab问题之重置root密码

WinJay
2021-09-10 / 0 评论 / 0 点赞 / 118 阅读 / 1,484 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2021-12-15,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

登录gitlab服务器

本环境是用docker安装

1、进入gitlab容器

docker exec -it gitlab bash

2、切换git用户

su - git

3、查看gitlab组件

ls

4、进入gitlab控制台

gitlab-rails console production

或者(不同版本有区别)

gitlab-rails console -e production

5、查询gitlab超管用户信息

user = User.where(id:1).first

image.png

image.png

如下提示代表成功:

irb(main):004:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 7dc9cc44-0296-4a62-8b9a-335d4d5da11b) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true

root@9a8481b3b704:/# su git
$ ls
RELEASE  assets  bin  boot  dev  etc  home  lib  lib32	lib64  libx32  linuxrc	media  mnt  opt  proc  root  run  sbin	srv  sys  tmp  usr  var
$ gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
 GitLab:       14.2.3 (2324101daeb) FOSS
 GitLab Shell: 13.19.1
 PostgreSQL:   12.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.1.3.2)
irb(main):001:0> user = User.where(id:1).first
=> #<User id:1 @Root>
irb(main):002:0> user.password=12345678
=> 12345678
irb(main):003:0> user.password_confirmation=12345678
=> 12345678
irb(main):004:0> user.save!
Enqueued ActionMailer::MailDeliveryJob (Job ID: ad6ce6b1-3454-490a-b4a3-22c2464da178) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007fb987eef848 @uri=#<URI::GID gid://gitlab/User/1>>]}
=> true
irb(main):005:0>
0

评论区