访问GitLab的PostgreSQL数据库

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

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

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

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

[[email protected] ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
gitlab-www:x:496:493::/var/opt/gitlab/nginx:/bin/false
git:x:495:492::/var/opt/gitlab:/bin/sh
gitlab-redis:x:494:491::/var/opt/gitlab/redis:/bin/false
gitlab-psql:x:493:490::/var/opt/gitlab/postgresql:/bin/sh  //gitlab的postgresql用户

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

[[email protected] ~]# 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

时间: 2024-08-09 19:51:53

访问GitLab的PostgreSQL数据库的相关文章

gitlab操作postgresql 数据库

切换到  gitlab-psql 用户下. 然后使用gitlab内部的psql命令进入postgresql数据库内部. $ /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production 然后操作数据库的CRDU.

Holer实现外网访问本地PostgreSQL数据库

外网访问内网PostgreSQL数据库 内网主机上安装了PostgreSQL数据库,只能在局域网内访问,怎样从公网也能访问本地PostgreSQL数据库? 本文将介绍使用holer实现的具体步骤. 1. 准备工作 1.1 安装并启动PostgreSQL数据库 默认安装的PostgreSQL数据库端口是5432. 2. 实现步骤 2.1 下载并解压holer软件包 Holer软件包:holer-xxx.tar.gz Holer支持各种OS系统平台,请选择跟本地OS类型匹配的holer软件包. 2.

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

PostgreSQL跨库访问有3种方法:Schema,dblink,postgres_fdw. 方法A:在PG上建立不同SCHEMA,将数据和存储过程分别放到不同的schema上,经过权限管理后进行访问. 方法A的示例如下: 测试1(测试postgres超级用户对不同schema下对象的访问) 查看当前数据库中的schema postgres=# \dn List of schemas Name | Owner -------------------+--------- dbms_job_pro

C#访问postgresql数据库

最近开始做C#的DotNet的工作,因为对PostgreSQL数据库比较有兴趣,所以自己研究了一下如何访问PostgreSQL的 数据库的问题. 1.为了访问PostgreSQL数据库,需要从pgfoundry网站,下载Npgsql .Net Data Provider for Postgresql的组件. 访问 URL:http://pgfoundry.org/frs/?group_id=1000140 注:因为使用的是DotNet3.5,所以下载了Npgsql2.0.6-bin-ms.net

C#访问PostGreSQL数据库的方法 http://www.jb51.net/article/35643.htm

这次的项目中的一个环节要求我把PostGreSQL数据取出来,然后放到SqlServer里,再去处理分析. http://www.jb51.net/article/35643.htm - 我对PostGreSQL只是一知半解,记录这个过程是希望如果以后微软技术方向的人遇到类似的需求,可以有个比较直接的的参考. 在不熟悉的知识领域里,总是有搜索引擎可以帮到我. 初步了解PostGreSQL数据库及数据形态 首先我想看看PostGreSQL的数据库以及我想要获取的数据形态是什么样子的,Linux和P

PostgreSQL数据库内核分析 笔记(这本书没有怎么很好的看,主要就是一些数据结构、概念和流程的文字介绍)

PostgreSQL数据库内核分析 跳转至: 导航. 搜索 目录 1系统概述 2体系结构 3存储管理 4索引 5查询编译 6查询执行 7事务处理与并发控制 8数据库安全 9附录A 用Eclipse开发和调试 系统概述 初始化数据库:./initdb --no-locale -D ../data ./pg_ctl start -D ../data 数据库命令:initdb createuser dropuser createdb dropdb pg_dump pg_restore pg_ctl v

[SQL]远程使用PostgreSQL Studio可视化查看PostgreSQL数据库

1.下载 前往官网地址下载最新的PostgreSQL Studio,我下载的是 pgstudio_1.2-bin .zip,因为我的电脑里面没有tomcat. 如果电脑里有配置好tomcat,可以下载pgstudio_1.2.zip,解压之后是一个war包. 下载地址:http://www.postgresqlstudio.org/download/ 2.解压 将压缩文件解压,可以看到如下目录: 3.运行 在bin目录下运行,启动tomcat: ./catalina.sh run 4.查看 浏览

Ubuntu下访问Windows中Postgresql

因为项目的原因,需要将Ubuntu中的一些信息记录到Windows中的Postgresql数据库中,查看网上信息,最后成功了,特地记录以下,需要以下步骤: (1)在Windows中Postgresql目录下找到pg_hba.conf文件,并做修改. 在此文件中添加一行,格式参考下面七种: local      database  user  auth-method  [auth-option] host       database  user  CIDR-address  auth-metho

PostgreSQL介绍以及如何开发框架中使用PostgreSQL数据库

最近准备下PostgreSQL数据库开发的相关知识,本文把总结的PPT内容通过博客记录分享,本随笔的主要内容是介绍PostgreSQL数据库的基础信息,以及如何在我们的开发框架中使用PostgreSQL数据库,希望大家多多提意见. 1.PostgreSQL数据库介绍 PostgreSQL是以加州大学伯克利分校计算机系开发的 POSTGRES,现在已经更名为PostgreSQL.它具有很多不错的特点: 开源:PostgreSQL 是一个自由的对象-关系数据库服务器(数据库管理系统),它在灵活的 B