訪問GitLab的PostgreSQL資料庫

來源:互聯網
上載者:User

標籤:message   bash   names   blog   ati   main   not   build   emoji   

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/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  //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

訪問GitLab的PostgreSQL資料庫

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.