重置gitlab的密码——在命令行重置

1、Gitlab查看用户id号的方法

通过api接口查询

接口查询地址: http://10.36.192.142/api/v4/users?username=root
[
    {
        "id": 1,
        "username": "root",
        "name": "Administrator",
        "state": "active",
        "locked": false,
        "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
        "web_url": "http://10.36.192.142/root"
    }
]

2、在命令行修改root用户密码

[root@localhost ~]# gitlab-rails console
--------------------------------------------------------------------------------
 Ruby:         ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]
 GitLab:       16.5.2-jh (351502d481d) EE
 GitLab Shell: 14.29.0
 PostgreSQL:   13.11
------------------------------------------------------------[ booted in 95.62s ]
Loading production environment (Rails 7.0.8)
irb(main):001:0> root = User.where(id: 1).first         # id为1的是超级管理员
=> #<User id:1 @root>
irb(main):002:0> root.password = 'Ll123456@'             # 密码必须至少8个字符
=> "Ll123456@"
irb(main):009:0> root.save!                             # 如没有问题 返回true
=> true
irb(main):010:0>                                        # 退出

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值