本文将对Gitlab的用户信息数据批量导出进行操作说明!
GitLab版本:GitLab Community Edition 13.5.1
思路
登陆Gitlab服务器进行数据库登陆、数据查询及信息导出操作。
操作步骤
1、根据配置文件,定位数据库相关信息
[root@l-git4 ~]# cat /var/opt/gitlab/gitlab-rails/etc/database.yml
2、查看Gitlab对应的系统用户
[root@l-git4 ~]# cat /etc/passwd | grep gitlab
3、切换用户gitlab-psql
[root@l-git4 ~]# su - gitlab-psql
4、登陆数据库(-h指定host,-d指定数据库) 使用第1步获取的信息
-sh-4.2$ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production
# 查看帮助信息
gitlabhq_production=# \h
# 查看数据库
gitlabhq_production=# \l
# 查看库中的表(执行命令后,按回车键显示更多表信息)
gitlabhq_production=# \dt
# 通过筛查,可在库中找到users表,相关用户信息都记录在表中!
# 查看users表结构
gitlabhq_production=# \d users
# 查看表信息
gitlabhq_production=# SELECT * FROM users;
# 查看users表中的name字段
gitlabhq_production=# SELECT name FROM users;
5、登出数据库
gitlabhq_production=# \q
6、根据需要提取的信息,确定表users中的字段,进行导出操作
-sh-4.2$ echo 'select name,username,email,state from users;' |psql -h /var/opt/gitlab/postgresql -d gitlabhq_production > userinfo.txt
7、用户信息已在/var/opt/gitlab/postgresql/userinfo.txt文件中
部分内容转自:https://www.cnblogs.com/kazihuo/p/11200585.html
点击查看:GitLab批量创建用户