編輯配置文件
# 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連接Postgresql
做了上面的配置,我們可以使用Navicat Premium 連接postgresql,因為對postgresql不是很熟,圖形管理方便點。