gitlab忘记root密码解决方法

复制代码

#切换到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用户进行登录,这次可以正常登录了。

复制代码
posted @   YYQ-  阅读(184)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示