#切换到git用户
[root@gitlab_3_45 ~]# su - git
#查看gitlab-rails的目录
-sh-4.2$ ls -l gitlab-rails
total 40
drwx------ 2 git root 4096 Feb 25 2020 etc
-rw-r--r-- 1 root root 8 Feb 25 2020 REVISION
-rw-r--r-- 1 root root 58 Feb 25 2020 RUBY_VERSION
drwxr-x--x 7 git gitlab-www 4096 Feb 25 2020 shared
drwxr-x--- 2 git gitlab-www 4096 Jan 5 2022 sockets
drwx------ 2 git root 4096 Feb 27 2018 tmp
drwx------ 2 git root 4096 Feb 25 2020 upgrade-status
drwx------ 2 git root 4096 Feb 27 2018 uploads
-rw-r--r-- 1 root root 7 Feb 25 2020 VERSION
drwx------ 2 git root 4096 Feb 27 2018 working
#进入到gitlab-rails的目录
-sh-4.2$ cd gitlab-rails
#输入gitlab-rails console production进入gitlab的命令行
-sh-4.2$ gitlab-rails console production
-------------------------------------------------------------------------------------
Gitlab: 10.8.7 (eb600b0)
Gitlab Shell: 7.1.2
postgresql: 9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0>
#查询id为1的用户
irb(main):002:0* user = User.where(id:1).first
=> #<User id:1 @root>
#user.password='xxxxxxxxxxxx'修改密码为xxxxxxxxxxxx
irb(main):003:0> user.password='xxxxxxxxxxxx'
=> "xxxxxxxxxxxx"
#user.save!保存刚刚修改密码操作
irb(main):004:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 88f1214c-5c94-35c2-8b27-70a54123471r24) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true
#退出
irb(main):005:0> exit
操作完成之后,再次回到登录窗口页面,重新使用root用户进行登录,这次可以正常登录了。