1.登陆gitlab的安装服务查看配置文件

cat /var/opt/gitlab/gitlab-rails/etc/database.yml 

production:
adapter: postgresql
encoding: unicode
collation:
database: gitlabhq_production //数据库名
pool:
username: 'gitlab' //用户名
password:
host: '/var/opt/gitlab/postgresql' //主机
port:
socket:
sslmode:
sslrootcert:
sslca:

查看/etc/passwd文件里边gitlab对应的系统用户

[root@localhost ~]# cat /etc/passwd
root:x:::root:/root:/bin/bash
gitlab-www:x::::/var/opt/gitlab/nginx:/bin/false
git:x::::/var/opt/gitlab:/bin/sh
gitlab-redis:x::::/var/opt/gitlab/redis:/bin/false
gitlab-psql:x::::/var/opt/gitlab/postgresql:/bin/sh //gitlab的postgresql用户

2.根据上面的配置信息登陆postgresql数据库

[root@localhost ~]# su - gitlab-psql     //登陆用户

-sh-4.1$ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production   连接到gitlabhq_production库

psql (9.2.18)
Type "help" for help.

gitlabhq_production=#  \h    查看帮助命令

Available help:
ABORT CREATE FUNCTION DROP TABLE
ALTER AGGREGATE CREATE GROUP DROP TABLESPACE
ALTER COLLATION CREATE INDEX DROP TEXT SEARCH CONFIGURATION
ALTER CONVERSION CREATE LANGUAGE DROP TEXT SEARCH DICTIONARY
ALTER DATABASE CREATE OPERATOR DROP TEXT SEARCH PARSER
ALTER DEFAULT PRIVILEGES CREATE OPERATOR CLASS DROP TEXT SEARCH TEMPLATE
ALTER DOMAIN CREATE OPERATOR FAMILY DROP TRIGGER
ALTER EXTENSION CREATE ROLE DROP TYPE

……………………………………………………………………………………………………………………

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-# \dt   //查看多表
List of relations
Schema | Name | Type | Owner
--------+--------------------------------------+-------+--------
public | abuse_reports | table | gitlab
public | appearances | table | gitlab
public | application_settings | table | gitlab
public | audit_events | table | gitlab
public | award_emoji | table | gitlab
public | boards | table | gitlab
public | broadcast_messages | table | gitlab

……………………………………………………………………………………………………………………

gitlabhq_production-# \d abuse_reports    //查看单表
Table "public.abuse_reports"
Column | Type | Modifiers
--------------+-----------------------------+------------------------------------------------------------
id | integer | not null default nextval('abuse_reports_id_seq'::regclass)
reporter_id | integer |
user_id | integer |
message | text |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
message_html | text |
Indexes:
"abuse_reports_pkey" PRIMARY KEY, btree (id)

gitlabhq_production-# \di    //查看索引
List of relations
Schema | Name | Type | Owner | Table

--------+-----------------------------------------------------------------+-------+--------+--------------------------------
------
public | abuse_reports_pkey | index | gitlab | abuse_reports
public | appearances_pkey | index | gitlab | appearances
public | application_settings_pkey | index | gitlab | application_settings
public | audit_events_pkey | index | gitlab | audit_events
public | award_emoji_pkey | index | gitlab | award_emoji
public | boards_pkey | index | gitlab | boards
public | broadcast_messages_pkey | index | gitlab | broadcast_messages
public | chat_names_pkey | index | gitlab | chat_names
public | ci_application_settings_pkey | index | gitlab | ci_application_settings
public | ci_builds_pkey | index | gitlab | ci_builds
public | ci_commits_pkey | index | gitlab | ci_commits

………………………………………………………………………………………………………………………………………………

gitlabhq_production=# SELECT spcname FROM pg_tablespace;  //查看所有表空间

spcname
------------
pg_default
pg_global
(2 rows)

gitlabhq_production-# \q    //退出psql
-sh-4.1$ exit                //退出登录用户
logout

访问GitLab的PostgreSQL数据库-(3)的更多相关文章

  1. 访问GitLab的PostgreSQL数据库,查询、修改、替换等操作

    1.登陆gitlab的安装服务查看配置文件 cat /var/opt/gitlab/gitlab-rails/etc/database.yml production: adapter: postgre ...

  2. 访问GitLab的PostgreSQL数据库

    1.登陆gitlab的安装服务查看配置文件 cat /var/opt/gitlab/gitlab-rails/etc/database.yml production: adapter: postgre ...

  3. 怎样从外网访问内网PostgreSQL数据库?

    本地安装了一个PostgreSQL数据库,只能在局域网内访问到,怎样从外网也能访问到本地的PostgreSQL数据库呢?本文将介绍具体的实现步骤. 1. 准备工作 1.1 安装并启动PostgreSQ ...

  4. 更改配置:远程访问gitlab的postgresql数据库

    作为这篇文章的补充: 将gitlab中的postgresql数据库开通远程访问 https://www.cnblogs.com/andy9468/p/10609682.html 替代(二)中的2.3. ...

  5. gitlab访问用户安装的postgresql数据库

    1.先将gitlab默认安装的postgresql的数据库中的数据,导入到用户安装的postgresql数据 用Navicat迁移数据.函数不用迁移. 2.配置gitlab对postgresql数据库 ...

  6. 将gitlab中的postgresql数据库开通远程访问

    postgresql数据库是gitlab的一个配置数据库,记录gitlab的一些配置信息. 我们访问gitlab中的postgresql数据有本地命令行访问和远程可视化软件访问2种方式. (一)本地命 ...

  7. PostgreSQL数据库中跨库访问解决方案

    PostgreSQL跨库访问有3种方法:Schema,dblink,postgres_fdw. 方法A:在PG上建立不同SCHEMA,将数据和存储过程分别放到不同的schema上,经过权限管理后进行访 ...

  8. C#访问postgresql数据库

    最近开始做C#的DotNet的工作,因为对PostgreSQL数据库比较有兴趣,所以自己研究了一下如何访问PostgreSQL的 数据库的问题. 1.为了访问PostgreSQL数据库,需要从pgfo ...

  9. C/C++访问PostgreSQL数据库

    编号:1011时间:2016年5月17日09:46:01功能:Windows环境下C/C++访问PostgreSQL数据库https://segmentfault.com/a/119000000062 ...

随机推荐

  1. this关键字制定对象的属性

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. C语言从零开始(十四)-字符串处理

    在软件开发过程中,字符串的操作相当频繁.在标准C语言库中提供了很多字符串处理的函数.今天我们来介绍一些常用的字符串处理函数.1. 字符串输入输出1.1 printf() scanf() 之前我们学习过 ...

  3. vim 编辑基础使用-----linux编程

    Linux系统编程: VIM编辑器 | VIM Introduce 学习 vim 并且其会成为你最后一个使用的文本编辑器.没有比这个更好的文本编辑器了,非常地难学,但是却不可思议地好用. 我建议下面这 ...

  4. C语言中的正负数及其输出

    在数学中,数字有正负之分.在C语言中也是一样,short.int.long 都可以带上正负号,例如: //负数 ; short a2 = -0x2dc9; //十六进制 //正数 ; ; //八进制 ...

  5. intellij中使用git插件将项目上传到码云

    参考帖子: git上传本地Intellij idea 项目到码云的git仓库中(评论中有彩蛋,一定要看) IntelliJ-IDEA和Git.GitHub.Gitlab的使用 使用idea上传项目到码 ...

  6. Church 整数前驱的推导

    Church 整数前驱的推导比其后继复杂得多,wiki中一个前驱的定义据王垠的博客里说,是他一个数学系的同学花一星期时间推导出来的, 其定义确实比其它介绍lambda的文章中用pair来实现(据说是图 ...

  7. 【多线程系列】AQS CAS简单介绍

    一.什么是CAS CAS(Compare And Swap),即比较并交换.是解决多线程并行情况下使用锁造成性能损耗的一种机制,CAS操作包含三个操作数——内存位置(V).预期原值(A)和新值(B). ...

  8. iPhone 上如何通过 Safari 使用 Pocket

     在开始之前,请确认你的机器上已经安装了 Pocket  应用软件. 如何安装 1.打开Pocket应用,点击左上角的菜单(三条横岗),找到最下面的 Help ,点击 How To Save ,找到 ...

  9. C# XtraGrid的行指示器(RowIndicator)行号以及图标设置

    以下是几种对Xtragrid的行指示器的几种操作方法,在实际场景当中,很多都需要用到,直接上效果图和源码 一.基本篇—设置表头行号 1.效果图 2.实现方法 需要对XtraGrid事件CustomDr ...

  10. centos7和Ubuntu上的关机需要手动关闭电源的问题

    author:heandsen chen date: 2018-11-11  20:36:38. # halt  执行后会出现这个问题 解决办法: # init 0 # shutdown -h now ...