docker版gitlab忘记管理员密码

moonjerx
2023-11-17 / 0 评论 / 58 阅读 / 正在检测是否收录...

一、进入容器

  • 进入容器

    docker exec -it gitlab /bin/sh

  • 打开生产数据库控制台

    gitlab-rails console -e production

# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [x86_64-linux]
 GitLab:       15.10.0-ee (defe6e7f882) EE
 GitLab Shell: 14.18.0
 PostgreSQL:   13.8
------------------------------------------------------------[ booted in 19.46s ]
Loading production environment (Rails 6.1.7.2)

二、修改用户密码

  • 查询id为1的用户名
    user = User.where(id: 1).first
  • 修改密码
    user.password='new_pwd'
  • 确认密码
    user.password_confirmation='new_pwd'
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password='new_pwd'
=> "new_pwd"
irb(main):003:0> user.password_confirmation = 'new_pwd'
=> "new_pwd"
irb(main):004:0> user.save
=> true
0

评论 (0)

取消

您的IP: