gitlab控制台重置root密码(其他账户密码)
调用接口获取用户IDhttp://giturl:端口/api/v4/users?username=root登录gitlab控制台我是使用docker 部署的gitlab,我需要先进入容器docker exec -it gitlab bashGitLab 版本不同,命令会有所不同(网上说的而基本都是gitlab-rails console production ),推荐大家直接上 GitLab 官网
·
调用接口获取用户ID
http://giturl:端口/api/v4/users?username=root
登录gitlab控制台
我是使用docker 部署的gitlab,我需要先进入容器
docker exec -it gitlab bash
GitLab 版本不同,命令会有所不同(网上说的而基本都是gitlab-rails console production
),推荐大家直接上 GitLab 官网去找对应版本的命令
我使用gitlab-rails console production
是进不去GitLab 控制台的;
root@c99d7a53d0ac:/# gitlab-rails console production
Traceback (most recent call last):
8: from bin/rails:4:in `<main>'
7: from bin/rails:4:in `require'
6: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.1.4.6/lib/rails/commands.rb:18:in `<top (required)>'
5: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.1.4.6/lib/rails/command.rb:48:in `invoke'
4: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.1.4.6/lib/rails/command/base.rb:69:in `perform'
3: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
2: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
1: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.1.4.6/lib/rails/commands/console/console_command.rb:95:in `perform': wrong number of arguments (given 1, expected 0) (ArgumentError)
9: from bin/rails:4:in `<main>'
8: from bin/rails:4:in `require'
7: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.1.4.6/lib/rails/commands.rb:18:in `<top (required)>'
6: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.1.4.6/lib/rails/command.rb:48:in `invoke'
5: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.1.4.6/lib/rails/command/base.rb:69:in `perform'
4: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
3: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
2: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:20:in `run'
1: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:34:in `rescue in run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:525:in `handle_argument_error': ERROR: "rails console" was called with arguments ["production"] (Thor::InvocationError)
Usage: "rails console [options]"
输入正确版本对应的命令gitlab-rails console -e production
出现下面的显示,表示我们成功进入控制台
root@c99d7a53d0ac:/# gitlab-rails console -e production
--------------------------------------------------------------------------------
Ruby: ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
GitLab: 14.8.2 (c7be43f6dd3) FOSS
GitLab Shell: 13.23.2
PostgreSQL: 12.7
------------------------------------------------------------[ booted in 36.66s ]
Loading production environment (Rails 6.1.4.6)
irb(main):001:0>
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = 'secret_passwd'
=> "secret_passwd"
irb(main):003:0> user.password_confirmation = 'secret_passwd'
=> "secret_passwd"
irb(main):004:0> user.save!
然后使用重制后的密码进行登陆即可
更多推荐
已为社区贡献8条内容
所有评论(0)