Skip to content
On this page

GitLab 重置密码

GitLab in docker

  1. 进入到容器当中

    $ docker exec -it gitlab /bin/bash
    
    $ docker exec -it gitlab /bin/bash
    
  2. Ruby on Rails console

    $ gitlab-rails console production
    
    $ gitlab-rails console production
    
  3. 查找root用户

    irb(main):006:0> user = User.where(id: 1).first
    
    irb(main):006:0> user = User.where(id: 1).first
    
    • 或者按照邮箱查找用户

      irb(main):006:0> user = User.find_by(email: 'admin@example.com')
      
      irb(main):006:0> user = User.find_by(email: 'admin@example.com')
      
  4. 重置密码(要求不少于8位)

    irb(main):006:0> user.password = 'secret_pass'
    irb(main):006:0> user.password_confirmation = 'secret_pass'
    
    irb(main):006:0> user.password = 'secret_pass'
    irb(main):006:0> user.password_confirmation = 'secret_pass'
    
  5. 保存更改

    irb(main):006:0> user.save!
    
    irb(main):006:0> user.save!