返回列表 发布新帖

【root账户误删除】恢复求助

80 3
发表于 2024-9-11 10:05:06 | 显示全部楼层 阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×

麻烦各位高手告诉我如何恢复root账号或者重新创建管理员账户。

gitlab版本信息: Ruby: ruby 3.1.5p253 (2024-04-023 revision 1945f8dc0e) [x86_64-linux] GitLab: 17.3.1-jh (e13c047548d) EE GitLab Shell: 14.38.0 PostgreSQL: 14.11

使用restful api批量删除用后,gitlab网站无法登录了提示封禁。

0d68b00d43dd917541eac4d4c9c75f2.png

技术支持给的命令不能解决问题:

1.重置root密码,执行了但是还是提示封禁: gitlab-rake "gitlab:password:reset[root]"

e095a407886b07f60c94130c51cbebc.png

2.创建新的管理员账户,执行了命令报错Validation failed: Namespace can't be blank: user = User.new(username: 'new_admin', email: 'new_admin@example.com', name: 'New Admin', password: 'password', password_confirmation: 'password') user.admin = true user.save!

image.png

回复

使用道具 举报

评论3

ethan楼主Lv.1 发表于 2024-9-11 10:25:38 | 显示全部楼层
搞定了,命令如下:
登录到GitLab的虚拟机。
进入GitLab Rails控制台:
  1. gitlab-rails console
复制代码

在控制台中执行以下命令
  1. user = User.find_by(username: 'root')
  2. user.admin = true
  3. user.state = 'active'
  4. user.save
复制代码
回复

使用道具 举报

zookeeperLv.7 发表于 2024-9-11 12:05:24 | 显示全部楼层
本帖最后由 zookeeper 于 2024-9-11 12:07 编辑

参考:
user = User.new(username: 'new_admin', email: 'new_admin@example.com', name: 'New Admin', password: 'password', password_confirmation: 'password')
u.assign_personal_namespace(Organizations::Organization.default_organization)
user.admin = true
u.skip_confirmation!
user.save!
回复

使用道具 举报

ethan楼主Lv.1 发表于 2024-9-11 13:47:52 | 显示全部楼层
zookeeper 发表于 2024-9-11 12:05
参考:
user = User.new(username: 'new_admin', email: 'new_admin@example.com', name: 'New Admin', pas ...

已经解决了,
  1. user = User.find_by(username: 'root')
  2. user.state = 'active'
  3. user.admin = true
  4. user.save
复制代码
回复

使用道具 举报

意见建议

Email:forum@gitlab.cn
  • 关注公众号
  • 添加专业顾问
Copyright © 2001-2024 极狐GitLab论坛 版权所有 All Rights Reserved. 鄂ICP备2021008419号-1|鄂公网安备42018502006137号
关灯 快速发帖
扫一扫添加专业顾问
返回顶部
快速回复 返回顶部 返回列表