惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
GbyAI
GbyAI
U
Unit 42
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
D
DataBreaches.Net
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
Martin Fowler
Martin Fowler
月光博客
月光博客
MongoDB | Blog
MongoDB | Blog
MyScale Blog
MyScale Blog
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
罗磊的独立博客
B
Blog RSS Feed
J
Java Code Geeks
The GitHub Blog
The GitHub Blog

git入门系列 on 打工人日志

CI/CD 可观察性-基于grafana sonarqube docker安装和配置 SSH 通过 443 端口连接 GitHub ansible 命令 Git 规则 git版本控制 CICD 概念 git使用方法 Jenkins 安装与使用 ansible 安装和部署 gitlab与github同步项目 git技巧 gitlab CI/CD 的使用 Markdown教程
Gitlab批量导出用户
2022-01-14 · via git入门系列 on 打工人日志

Gitlab 批量导出用户

登陆 Gitlab 服务器进行数据库登陆、数据查询及信息导出操作。

操作步骤

  1. 根据配置文件,定位数据库相关信息
1cat /var/opt/gitlab/gitlab-rails/etc/database.yml

exportuser1

  1. 查看 Gitlab 对应的系统用户
1cat /etc/passwd | grep gitlab

exportuser2

  1. 切换用户 gitlab-psql
  1. 登陆数据库(-h 指定 host,-d 指定数据库) 使用第 1 步获取的信息
1psql -h /var/opt/gitlab/postgresql -d gitlabhq_production

(1) 查看帮助信息

1gitlabhq_production=# \h

(2) 查看数据库

1gitlabhq_production=# \l

(3) 查看库中的表(执行命令后,按回车键显示更多表信息)

1gitlabhq_production=# \dt

(4) 通过筛查,可在库中找到 users 表,相关用户信息都记录在表中!

1gitlabhq_production=# \d users

(5) 查看表信息

1gitlabhq_production=# SELECT * FROM users;

(6) 查看 users 表中的 name 字段

1gitlabhq_production=# SELECT name FROM users;

(7)登出数据库

1gitlabhq_production=# \q
  1. 根据需要提取的信息,确定表 users 中的字段,进行导出操作
1echo 'select name,username,email,state from users;' |psql -h /var/opt/gitlab/postgresql -d gitlabhq_production > userinfo.txt

存储在/var/opt/gitlab/postgresql/userinfo.txt