su - git
    gitlab-rails console production
    user = User.where(email: 'admin@localhost').first 或者 User.where(id:1).first
    user.password = 'yourpassword'
    user.save!

演示:

    root@115:/var/opt/gitlab# su - git
    $ gitlab-rails console production
    -------------------------------------------------------------------------------------
     GitLab:       11.4.5 (f5536c6)
     GitLab Shell: 8.3.3
     postgresql:   9.6.8
    -------------------------------------------------------------------------------------
    Loading production environment (Rails 4.2.10)
    irb(main):001:0> user = User.where(email: '1480717918@qq.com').first
    => #<User id:3 @fogfore>
    irb(main):002:0> user.password = 'password'
    => "password"
    irb(main):003:0> user.save!
    Enqueued ActionMailer::DeliveryJob (Job ID: 6866e79d-a3ec-4ffc-b699-9c77400493d0) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/3
    => true
    irb(main):004:0> 
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐