访问 GitLab 自带 PostgreSQL 数据库,查询、修改、替换等

  • 查看 PostgreSQL 配置信息:
$ cat /var/opt/gitlab/gitlab-rails/etc/database.yml 

# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.

production:
  adapter: postgresql
  encoding: unicode
  collation:
  # 数据库
  database: gitlabhq_production
  pool: 10
  # 用户名
  username: "gitlab"
  password:
  host: "/var/opt/gitlab/postgresql"
  port: 5432
  socket:
  sslmode:
  sslcompression: 0
  sslrootcert:
  sslca:
  load_balancing: {"hosts":[]}
  prepared_statements: false
  statements_limit: 1000
  fdw:
  • 查看 /etc/passwd 文件里边 gitlab 对应的系统用户
$ cat /etc/passwd
......
gitlab-psql:x:996:996::/var/opt/gitlab/postgresql:/bin/sh
......

# 切换到对应用户
$ su - gitlab-psql
  • 连接数据库
$ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production
psql (9.6.11)
Type "help" for help.

gitlabhq_production=#

后边使用 PostgreSQL 语法进行操作即可。

发表评论

电子邮件地址不会被公开。 必填项已用*标注