Gitlab忘记root用户密码解决办法

今天使用gitlab的时候发现管理员密码忘记,现将找回密码的过程记录。
(1)、查询gitlab用户的id号
可以进入gitlab数据库查询

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# gitlab-rails dbconsole
psql (9.6.3)
Type "help" for help.
# 连接数据库
\c gitlabhq_production
You are now connected to database "gitlabhq_production" as user "gitlab".
# 查看用户root的id
select id,name,username from users where username = 'root';
id |     name      | username
----+---------------+----------
1 | Administrator | root
(1 row)

退出
\q
could not save history to file "/var/opt/gitlab/.psql_history": Permission denied

Gitlab忘记root用户密码解决办法
通过查询我们知道root用户的id号为1

也可以通过api接口查询用户的id号
比如查看gitlab的root用户id
在浏览器页面里直接访问"http://173.16.200.83:29091/api/v4/users?username=root"

(2)、忘记Gitlab的root用户密码的重置方法
重置用户密码之前,需要知道用户的id号, 可以通过上面的方法查询到用户的id号信息

1
2
3
4
5
6
#  gitlab-rails console production
user = User.where(id: 1).first
user.password = 'gitlab200.83oms'
user.password_confirmation = 'gitlab200.83oms'
user.save!
quit

通过上面的方法我们可以给gitlab的root密码重置为gitlab200.83oms
Gitlab忘记root用户密码解决办法

相关新闻

联系我们

全国服务热线

400-033-9553

电子邮件:admin@example.com
工作时间:09:00-17:00 周一至周五

在线客服
关注微信
关注微信
分享本页
返回顶部