1. 查看配置文件
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:
sslrootcert:
sslca:
load_balancing: {"hosts":[]}
prepared_statements: false
statements_limit: 1000
fdw:
2. 查看用户
cat /etc/passwd
git:x:995:992::/var/opt/gitlab:/bin/sh
gitlab-psql:x:993:990::/var/opt/gitlab/postgresql:/bin/sh
gitlab-prometheus:x:992:989::/var/opt/gitlab/prometheus:/bin/sh
3. 登录
su - gitlab-psql //登录用户
Last login: Sun Apr 8 21:57:52 CST 2018 on pts/0
-sh-4.2$
//之后输入
-sh-4.2$ psql -h /var/opt/gitlab/postgresql -d gitlabhq_production //连接到gitlabhq_production库
psql (9.6.8)
Type "help" for help.
gitlabhq_production=# //这时可以输入postgresql的命令了
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)
4. 登录其他用户
同理,可以使用 su - 用户名 的方式登录安装一些软件时自动创建的用户,如git用户,或jenkins用户
[root@localhost .ssh]# su - git
Last login: Sun Apr 8 22:00:25 CST 2018 on pts/0
-sh-4.2$ //现在就是以git用户的身份运行的,可以查看属于git用户和组的目录和文件