在 Debian 上重置 GitLab 密码,通常有两种常见场景:重置 Web 登录用户密码 和 忘记 root 密码。下面是最常用、最稳妥的方法。
sudo gitlab-rails console -e production
(如果是旧版本,可能是 gitlab-rake rails console)
user = User.find_by(username: 'root')
# 或者按邮箱
user = User.find_by(email: 'admin@example.com')
user.password = 'NewPassword123'
user.password_confirmation = 'NewPassword123'
user.save!
exit
⚠️ 密码需符合 GitLab 密码策略(通常至少 8 位)
(前提:SMTP 已正确配置)
直接使用上面的 方法一,这是最常见情况。
/etc/gitlab/gitlab.rbsudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
docker exec -it gitlab gitlab-rails console -e production
然后同样执行上面的 Ruby 命令。
如果你能告诉我:
我可以给你更精确的步骤。