重置gitlab管理员密码

gitlab web管理员登录密码忘记以后可以用如下方式修改密码(本演示系统为Linux-CentOS6.6):

[root@localhost ~]# gitlab-rails console production
Loading production environment (Rails 4.2.7.1)
irb(main):001:0> user=User.where(id:1).first //id为1的是超级管理员

敲回车键

=> #<User id: 1, email: "admin@example.com", created_at: "2017-02-09 11:03:08", updated_at: "2017-02-15 12:19:54", name: "Administrator", admin: true, projects_limit: 10, skype: "", linkedin: "", twitter: "", authentication_token: "M_ffJi-sRksyrz_dexor", theme_id: 2, bio: nil, username: "root", can_create_group: true, can_create_team: false, state: "active", color_scheme_id: 1, password_expires_at: nil, created_by_id: nil, last_credential_check_at: nil, avatar: nil, hide_no_ssh_key: false, website_url: "", notification_email: "admin@example.com", hide_no_password: false, password_automatically_set: false, location: nil, encrypted_otp_secret: nil, encrypted_otp_secret_iv: nil, encrypted_otp_secret_salt: nil, otp_required_for_login: false, otp_backup_codes: nil, public_email: "", dashboard: 0, project_view: 0, consumed_timestep: nil, layout: 0, hide_project_limit: false, otp_grace_period_started_at: nil, ldap_email: false, external: false, organization: nil, incoming_email_token: "dten2iwvt5zcm2su3280mybbo", authorized_projects_populated: true>

(注:红色部分标出管理员登录名)

irb(main):002:0>user.password = 'yourpassword' //密码必须至少8个字符

敲回车键
irb(main):003:0>user.save!

敲回车键

irb(main):003:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 99d8a108-2f13-4bdf-9ccc-d23d43d7a1c0) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true

 // 如没有问题 返回true

至此密码修改完成,可以用管理员名和修改好后的密码登陆了。

转载于:https://www.cnblogs.com/IT-Crowd/p/6412229.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值