Accessing Gitlab's PostgreSQL database

Source: Internet
Author: User
Tags create index postgresql psql

1. Login Gitlab Installation Services View configuration files

cat /var/opt/gitlab/gitlab-rails/etc/database.yml production:  adapter:postgresql  Encoding: Unicode  collation:  database:gitlabhq_production  //database name       gitlab'  //user name   password  :'/var/opt/gitlab /postgresql'  //host    5432  socket:  sslmode:  Sslrootcert:  Sslca:

View/etc/passwd files Gitlab corresponding system users inside

[Email protected] ~]#Cat/etc/passwdroot:x:0:0: root:/root:/bin/Bashgitlab-WWW:X:496:493::/var/opt/gitlab/nginx:/bin/falsegit:x:495:492::/var/opt/gitlab:/bin/SHGitlab-REDIS:X:494:491::/var/opt/gitlab/redis:/bin/falseGitlab-PSQL:X:493:490::/var/opt/gitlab/postgresql:/bin/SH  //PostgreSQL users of Gitlab

2. Log in to the PostgreSQL database based on the configuration information above

[[email protected] ~]# su-gitlab-psql//login user

-sh-4.1$ psql-h/var/opt/gitlab/postgresql-d gitlabhq_production connect to Gitlabhq_production Library

Psql (9.2.18)
Type ' help ' for help.

gitlabhq_production=# \h View Help commands

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//View Database
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//View multiple tables
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//view single table
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    //View index
List of relations
Schema | Name | Type | Owner | Table

--------+-----------------------------------------------------------------+-------+--------+------ --------------------------
------
Public | abuse_reports_pkey | index | gitlab | abuse_reports
Public | appeara Nces_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 | boar DS
Public | broadcast_messages_pkey | index | gitlab | broadcast_messages
Public | chat_names_pkey | index | gitla B | Chat_names
Public | ci_application_settings_pkey | index | gitlab | ci_application_settings
Public | ci_builds_pke y | Index | Gitlab | Ci_builds
Public | ci_commits_pkey | index | gitlab | ci_commits

..................................................................................................................................................................

gitlabhq_production=# SELECT spcname from Pg_tablespace; View all table spaces

Spcname
------------
Pg_default
Pg_global
(2 rows)

gitlabhq_production-# \q//Exit Psql
-sh-4.1$ exit//Exit login User
Logout

Accessing Gitlab's PostgreSQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.