root用戶下:
安裝
yum install postgresql-server
初始化數(shù)據(jù)庫(kù)
postgresql-setup initdb
設(shè)置開機(jī)啟動(dòng)
systemctl enable postgresql.service
啟動(dòng)服務(wù)
systemctl start postgresql.service
切換用戶
su - postgres
postgres用戶下:
登錄postgresql控制臺(tái)
psql
PostgreSQL控制臺(tái)下:
為postgres用戶設(shè)置密碼
\password postgres;
輸入新密碼 YOUR_OWN_PWD
創(chuàng)建數(shù)據(jù)庫(kù)用戶test
CREATE USER test WITH PASSWORD 'YOUR_OWN_PWD';
創(chuàng)建數(shù)據(jù)庫(kù)TestCaseRepo
CREATE DATABASE TestCaseRepo OWNER test;
將TestCaseRepo數(shù)據(jù)庫(kù)的所有權(quán)限賦予test
GRANT ALL PRIVILEGES ON DATABASE TestCaseRepo to test;
退出psql控制臺(tái)
\q
回到root用戶:
修改/var/lib/pgsql/data/pg_hba.conf部分內(nèi)容猴凹,添加信任的連接ip
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.2.1/24 trust
設(shè)置允許通過ip地址連接肉津,修改/var/lib/pgsql/data/postgresql.conf部分內(nèi)容
listen_addresses = '*'
重啟服務(wù),使配置生效
systemctl restart postgresql.service
登錄數(shù)據(jù)庫(kù)(數(shù)據(jù)庫(kù)名稱需要小寫)
psql -U test -d testcaserepo -h 127.0.0.1 -p 5432