Gitlab忘记root用户密码解决办法
一、Gitlab忘记root用户密码,重置用户密码和查看用户ID号方法
1、Gitlab查看用户id号的方法
1)方法1:通过api接口查询
接口查询地址:http://gitlab的url/api/v4/users?username=用户名
比如查看gitlab的root用户id
在浏览器页面里直接访问"http://172.16.60.237/api/v4/users?username=root"
或者
在linux终端命令行里直接通过curl命令进行访问
[root@localhost ~]# curl http://172.16.60.237/api/v4/users?username=root
[{"id":1,"name":"Administrator","username":"root","state":"active","avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","web_url":"http://gitlab.example.com/root"}]
2)方法2:进入gitlab数据库查询
[root@localhost ~]# gitlab-rails dbconsole
psql (10.9)
Type "help" for help. gitlabhq_production=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------------+-------------+----------+-------------+-------------+---------------------------------
gitlabhq_production | gitlab | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | gitlab-psql | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | gitlab-psql | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/"gitlab-psql" +
| | | | | "gitlab-psql"=CTc/"gitlab-psql"
template1 | gitlab-psql | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/"gitlab-psql" +
| | | | | "gitlab-psql"=CTc/"gitlab-psql"
(4 rows) ## 连接数据库
gitlabhq_production=> \c gitlabhq_production
You are now connected to database "gitlabhq_production" as user "gitlab".
gitlabhq_production=> select id,name,username from users;
id | name | username
----+---------------+----------
1 | Administrator | root
(1 row)
## 查找账户id
gitlabhq_production=> select id from users where username = 'root';
id
----
1
(1 row) ==============================================================================================
2、忘记Gitlab的root用户密码的重置方法
如果忘记了Gitlab的root用户密码,则可以在服务器上面直接修改数据:
[root@localhost ~]# gitlab-rails console production #然后以此执行下面命令(需要提前查询用户的id号)
...> user = User.where(id: 1).first
...> user.password = 'secret_pass'
...> user.password_confirmation = 'secret_pass'
...> user.save!
例如重置root用户密码为root@123,root用户id为1
[root@localhost ~]# gitlab-rails console production
DEPRECATION WARNING: Passing the environment's name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -eoption instead. (called from require at bin/rails:4)
--------------------------------------------------------------------------------
GitLab: 12.2.0 (1c1d47c5974)
GitLab Shell: 9.3.0
PostgreSQL: 10.9
--------------------------------------------------------------------------------
Loading production environment (Rails 5.2.3)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = 'root@123'
=> "root@123"
irb(main):003:0> user.password_confirmation = 'root@123'
=> "root@123"
irb(main):004:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: e562694d-2a1b-4bad-843b-d8567ac51077) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", #<GlobalID:0x00007fae7e55bcc8 @uri=#<URI::GID gid://gitlab/User/1>>
=> true
irb(main):005:0> quit

-----------------------------------------------------------书山有路勤为径,学海无涯苦作舟-------------------------------------------------------------
Gitlab忘记root用户密码解决办法的更多相关文章
- CentOS忘记普通用户密码解决办法
普通用户忘记密码 1.使用root用户登录系统,找到/etc/shadow文件. 2.找到用户名开头的那一行,例如我的用户名为pds,,以冒号为分割符,红色部分是密码加密部分 pds:$1$Civop ...
- GitLab修改root用户密码
GitLab是一个私有的Git仓库,具有较好的项目管理和用户管理能力.对于普通用户而言,通过系统的重置密码,接受邮件即可解决,可是GitLab的管理员账号,缺省的邮箱是一个不存在的邮箱地址,所以没有办 ...
- mysql忘记帐号密码 解决办法
首先关闭mysql 使用命令行启动mysql(一般要找到mysql.ini文件) 在windows上mysql.ini文件可以通过查看当前mysql进程参数查看到,具体方法点此 在启动mysql命令行 ...
- Linux 忘记root登录密码解决方法
很多朋友经常会忘记Linux系统的root密码,linux系统忘记root密码的情况该怎么办呢?重新安装系统吗?当然不用!进入单用户模式更改一下root密码即可. 步骤如下: 重启linux系统 3 ...
- MySQL忘记root用户密码修改方法
一般来说在MySQL修改用户密码有好几种方法: 1.修改自己的密码可用: set password=password('123456'); 2.修改其它用户的密码可用: set password fo ...
- Linux忘记root登录密码解决方法
有时候由于长时间米有登录linux系统,等需要用的时候突然忘记root密码,怎么办?下面简单介绍解决方法. redhat 和 centos 6.5 可以,7.0以上未测 在系统重启后,不停地按”e”键 ...
- CentOS忘记用户名或者密码解决办法
方法一:如果用户名和密码都忘记了,可以用以下这个方法找回:(和第二种大步骤差不多,需注意3,4步) 1. 在出现grub画面时,用上下键选中你平时启动linux的那一项,然后按e键 2. 再次用上下键 ...
- mysql忘记root用户密码找回步骤
修改或找回root密码步骤1.修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出vi. 2.重新启动mys ...
- 利用lnmp一键安装的php环境忘记mysql,root用户密码解决方法
1.cd /lnmp1.5/tools/ 2.sh reset_mysql_root_password.sh 这样,即可完成修改!
随机推荐
- 攻防世界-crypto-easychallenge(.pyc反编译)
进入题目后下载附件,发现是一个.pyc文件. pyc是一种二进制文件,是由py文件经过编译后,生成的文件,是一种byte code,py文件变成pyc文件后,运行加载的速度会有所提高:另一反面,把py ...
- Databricks 第7篇:管理Secret
有时,访问数据要求您通过JDBC对外部数据源进行身份验证,可以使用Azure Databricks Secret来存储凭据,并在notebook和job中引用它们,而不是直接在notebook中输入凭 ...
- 记录Js动态加载页面.append、html、appendChild、repend添加元素节点不生效以及解决办法
今天再优化blog页面的时候添加了个关注按钮和图片,但是页面上这个按钮和图片时有时无,本来是搞后端的,被这个前端的小问题搞得抓耳挠腮的! 网上各种查询解决方案,把我解决问题的艰辛历程分享出来,希望大家 ...
- linux7下修改主机名的方式
在基于linux发行版的众多linux kernel 3.0以上,包括rhel7,centos7等提供多种修改linux主机名的方式 1.通过编辑/etc/hostname文件 2.命令hostnam ...
- java 利用异或^进行加密
package com.zcj.eg001; import java.nio.charset.Charset; import org.junit.Test; public class Encrypti ...
- OLED的波形曲线、进度条、图片显示(STM32 HAL库 模拟SPI通信 5线OLED屏幕)详细篇
少废话,先上效果图 屏幕显示效果 全家福 一.基础认识及引脚介绍 屏幕参数: 尺寸:0.96英寸 分辨率:128*64 驱动芯片:SSD1306 驱动接口协议:SPI 引脚说明: 二. ...
- 采用Sharding-JDBC解决分库分表
源码:Sharding-JDBC(分库分表) 一.Sharding-JDBC介绍 1,介绍 Sharding-JDBC是当当网研发的开源分布式数据库中间件,从 3.0 开始Sharding-JDBC被 ...
- Linux防火墙和iptables
1. CentOS 查看防火墙状态: systemctl status firewalld firewall-cmd --state 启停防火墙: # 开启 systemctl start firew ...
- Spring听课笔记(tg)
0. 地址:https://www.bilibili.com/video/av21335209 1.综述,Spring主要的复习要点集中在以下几点 -- Spring的整体结构,Maven依赖(环境搭 ...
- Java并发包源码学习系列:阻塞队列实现之SynchronousQueue源码解析
目录 SynchronousQueue概述 使用案例 类图结构 put与take方法 void put(E e) E take() Transfer 公平模式TransferQueue QNode t ...