接口查询地址:http://gitlab的url/api/v4/users?username=用户名
[{"id":1,"username":"root","name":"Administrator","state":"active","avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","web_url":"http://192.168.31.240:9090/root"}]
[root@localhost ~]# curl http://192.168.3.240:9090/api/v4/users?username=root
# 1 切换到git用户
[root@localhost ~]$ su - git
# 2.进入控交互控制台,注意:14.x版本必须加上 -e,否则会出现错误
[git@localhost ~]$ gitlab-rails console -e production
# 注意:14.x之前版本可以不加 -e,如:gitlab-rails console production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 14.6.0 (3bc07a0be9c) FOSS
GitLab Shell: 13.22.1
PostgreSQL: 12.7
--------------------------------------------------------------------------------
Loading production environment (Rails 6.1.4.1)
# 1.查询用户
## 1.1根据用户名查询
irb(main):001:0> user = User.where(username: "root").first
## 1.2.根据id查询
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
# 2.设置root用户的新密码
irb(main):002:0> user.password = 'root@123'
=> "root@123"
# 3.确认密码
irb(main):003:0> user.password_confirmation = 'root@123'
=> "root@123"
# 4.保存设置
irb(main):004:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: e562694d-2a1b-4bad-843b-d8567ac51077) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007fae7e55bcc8 @uri=#<URI::GID gid://gitlab/User/1>>
=> true
# 5.退出
irb(main):005:0> quit