您的位置:首页 > 数据库

gitlab 使用postgresql数据库的一些说明

2015-08-21 14:30 441 查看
# cd /var/opt/gitlab/postgresql/data

# vim pg_hba.conf      

  host    all         all  192.168.1.0/24  trust    添加这行,192.168.1.0/24这个段的ip地址不需要密码可以连接

# vim postgresql.conf 

   listen_addresses = '192.168.1.125'      修改监听地址为ip

# gitlab-ctl restart postgresql

# cd /opt/gitlab/embedded/

# # bin/psql -U gitlab -d gitlabhq_production -h 192.168.1.125             不用输入密码就可进来

psql (9.2.10)

Type "help" for help.

gitlabhq_production=> alter user gitlab with password 'gitlab'               修改gitlab密码,gitlab创建的数据库超级用户为gitlab-psql,想修改密码自己通过命令修改即可

gitlabhq_production-> \q               退出

# cd /var/opt/gitlab/postgresql/data

   host    all         all  192.168.1.0/24  md5      修改trust 为md5 ,即连接需要密码

# gitlab-ctl restart postgresql

# /opt/gitlab/embedded/bin/psql -U gitlab -d gitlabhq_production -h 192.168.1.125

Password for user gitlab:                                                                                 输入密码gitlab 回车就可以进来了

既然修改了数据库gitlab用户的密码,gitlab服务器中数据库配置文件,也需要修改,不然数据库连接不上

# cd /var/opt/gitlab/

# vim gitlab-rails/etc/database.yml 

  production:

  adapter: postgresql

  encoding: unicode

  database: gitlabhq_production

  pool: 10

  username: 'gitlab'

  password: 'gitlab'                   添加设置的密码

  host: 192.168.1.125               更改为ip地址

  port: 5432

# gitlab-ctl restart

ok了,可以去访问看看是否正常

做了上面的配置,我们可以使用Navicat Premium 连接postgresql,因为对postgresql不是很熟,图形管理方便点。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: