歡迎關(guān)注我的公眾號 [極智視界],獲取我的更多經(jīng)驗分享
大家好,我是極智視界,本文介紹一下 教你gitlab管理員密碼忘了怎么辦。
邀您加入我的知識星球「極智視界」,星球內(nèi)有超多好玩的項目實戰(zhàn)源碼和資源下載,鏈接:https://t.zsxq.com/0aiNxERDq
有時候你可能會忘了自己的 gitlab 管理員密碼,那么該怎么辦呢,該如何找回呢,我來教你。
有一種方法是如果你當時配置了郵箱的話,那么可以通過郵箱找回,就像下面這樣:
這里主要介紹另外一種方法,即通過服務控制臺命令行重置密碼的方式。
進入到 gitlab server 服務器的控制臺,進入到 gitlab 的 bin 目錄:
cd /opt/gitlab/bin
開始重置密碼:
sudo gitlab-rails console -e production
codingai@server:/opt/gitlab/bin$ sudo gitlab-rails console -e production
[sudo] password for codingai:
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 14.9.2 (56bec66a79f) FOSS
GitLab Shell: 13.24.0
PostgreSQL: 12.7
------------------------------------------------------------[ booted in 27.72s ]
Loading production environment (Rails 6.1.4.6)
irb(main):001:0>
然后可以通過如下命令查看有哪些注冊用戶,以及配套的用戶 id,這個步驟的目的是為了通過用戶 id 來精準定位到想修改的用戶的密碼,如下:
irb(main):001:0>User.all
=> #<ActiveRecord::Relation [#<User id:3 @alert-bot>, #<User id:4 @support-bot>, #<User id:1 @root>, #<User id:2 @codingai>, #<User id:3 @coke>]>
很明顯,咱們這里要改的就是 root,也就是對應于 id = 1,繼續(xù):
irb(main):002:0> u.User.where(id:1).first
Traceback (most recent call last):
1: from (irb):1
ArgumentError (wrong number of arguments (given 0, expected 1))
irb(main):003:0> u=User.where(id:1).first
=> #<User id:1 @root>
irb(main):004:0> u.password=12345678
=> 12345678
irb(main):005:0> u.password_confirmation=12345678
=> 12345678
irb(main):006:0> u.save!
=> true
irb(main):007:0> exit
通過如上的命令就把 root 的密碼重置為了 12345678 了,然后可以重新回到 web 登錄試試!
完整的命令如下:
codingai@server:/opt/gitlab/bin$ sudo gitlab-rails console -e production
[sudo] password for codingai:
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 14.9.2 (56bec66a79f) FOSS
GitLab Shell: 13.24.0
PostgreSQL: 12.7
------------------------------------------------------------[ booted in 27.72s ]
Loading production environment (Rails 6.1.4.6)
irb(main):001:0>User.all
=> #<ActiveRecord::Relation [#<User id:3 @alert-bot>, #<User id:4 @support-bot>, #<User id:1 @root>, #<User id:2 @codingai>, #<User id:3 @coke>]>
irb(main):002:0> u.User.where(id:1).first
Traceback (most recent call last):
1: from (irb):1
ArgumentError (wrong number of arguments (given 0, expected 1))
irb(main):003:0> u=User.where(id:1).first
=> #<User id:1 @root>
irb(main):004:0> u.password=12345678
=> 12345678
irb(main):005:0> u.password_confirmation=12345678
=> 12345678
irb(main):006:0> u.save!
=> true
irb(main):007:0> exit
好了,以上分享了 gitlab 管理員密碼忘了怎么辦的方法,希望我的分享能對你的學習有一點幫助。
【極智視界】
《極智開發(fā) | 教你gitlab管理員密碼忘了怎么辦》
暢享人工智能的科技魅力,讓好玩的AI項目不難玩。邀請您加入我的知識星球,星球內(nèi)我精心整備了大量好玩的AI項目,皆以工程源碼形式開放使用,涵蓋人臉、檢測、分割、多模態(tài)、AIGC、自動駕駛、工業(yè)等。不敢說會對你學習有所幫助,但一定非常好玩,并持續(xù)更新更加有趣的項目。https://t.zsxq.com/0aiNxERDq文章來源:http://www.zghlxwxcb.cn/news/detail-527178.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-527178.html
到了這里,關(guān)于極智開發(fā) | 教你gitlab管理員密碼忘了怎么辦的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!