postgres 退出_centos如何退出postges?
PostgreSQL強(qiáng)源象關(guān)系類(lèi)型數(shù)據(jù)庫(kù)系統(tǒng)能運(yùn)行于幾乎所主要操作系統(tǒng)包括Linux、Unix(AIX、BSD、HP-UX、SGI
IRIX、Mac OS、Solaris、Tru64)、Windows OS篇教程我習(xí)何CentOS7/6.5/6.4 server
建立PostgreSQL
1.安裝PostgreSQL
首先根據(jù)服務(wù)器架構(gòu)添加PostgreSQL庫(kù):
CentOS 6.x 32bit:
rpm -Uvh 1.noarch.rpm
CentOS 6.x 64bit:
rpm -Uvh
CentOS 7 64bit:
rpm -Uvh
于其發(fā)行版查看鏈接并建立庫(kù):
使用命令更新庫(kù):
yum update
使用命令安裝PostgreSQL:
yum install postgresql93-server postgresql93-contrib
使用命令初始化PostgreSQL數(shù)據(jù)庫(kù):
CentOS 6.x 系統(tǒng):
service postgresql-9.3 initdb
CentOS 7系統(tǒng):
/usr/pgsql-9.3/bin/postgresql93-setup initdb
啟PostgreSQL服務(wù)并使機(jī)自啟:
CentOS 6.x 系統(tǒng):
service postgresql-9.3 start
chkconfig postgresql-9.3 on
CentOS 7系統(tǒng):
systemctl enable postgresql-9.3
systemctl start postgresql-9.3
2.調(diào)整Iptables/Firewall
接調(diào)整防火墻站規(guī)則:
CentOS 6.x系統(tǒng):
vi /etc/sysconfig/iptables
并添加行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
退并保存文件重啟iptables服務(wù):
service iptables restart
CentOS系統(tǒng):
firewall-cmd --permanent –add-port=5432/tcp
firewall-cmd --permanent –add-port=80/tcp
firewall-cmd --reload
3.訪(fǎng)問(wèn)PostgreSQL用命令提示符
默認(rèn)情況數(shù)據(jù)庫(kù)名用戶(hù)名都postgres切換至用戶(hù)執(zhí)行相關(guān)操作:
su – postgres
輸入命令登陸:
psql
例輸:
psql (9.3.5)
Type "help" for help.
Postgres=#
通輸入\q退postgresql返命令終端:
4.設(shè)置用戶(hù)密碼
登陸至postgres命令提示符界面
su – postgres
psql
使用命令設(shè)置密碼
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q
輸入命令建立PostgreSQL系統(tǒng)管理工具
postgres=# CREATE EXTENSION adminpack;
CREATE EXTENSION
5.創(chuàng)建用戶(hù)數(shù)據(jù)庫(kù)
例:用戶(hù)名:senthil 密碼:centos 數(shù)據(jù)庫(kù)名:mydb
轉(zhuǎn)postgres用戶(hù)
su – postgres
創(chuàng)建用戶(hù)senthil
$ createuser senthil
創(chuàng)建數(shù)據(jù)庫(kù)
$ createdb mydb
現(xiàn)登陸至psql提示符界面用戶(hù)senthil設(shè)置密碼及授權(quán)數(shù)據(jù)庫(kù)mydb訪(fǎng)問(wèn):
$ psql
psql (9.3.5)
Type "help" for help.
postgres=# alter user senthil with encrypted password 'centos';
ALTER ROLE
postgres=# grant all privileges on database mydb to senthil;
GRANT
postgres=#
6.刪除用戶(hù)數(shù)據(jù)庫(kù)
首先轉(zhuǎn)postgres界面
su – postgres
輸入命令
$ dropdb
刪除用戶(hù)名輸入
$ dropuser
7.配置PostgreSQL-MD5認(rèn)證
MD5認(rèn)證需要客戶(hù)端提供MD5-encrypted 密碼便身份驗(yàn)證需要編輯 /var/lib/pgsql/9.3/data/pg_hba.conf文件:
vi /var/lib/pgsql/9.3/data/pg_hba.conf
添加或修改行:
[...]
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.1.0/24 md5
# IPv6 local connections:
host all all ::1/128 md5
[...]
重啟postgresql服務(wù)應(yīng)用更改
CentOS 6.x系統(tǒng)
service postgresql-9.3 restart
CentOS 7系統(tǒng)
systemctl restart postgresql-9.3
8.配置PostgreSQL-Configure TCP/IP
默認(rèn)情況TCP/IP連接行所其計(jì)算機(jī)用戶(hù)能連接postgresql編輯文件 /var/lib/pgsql/9.3/data/postgresql.conf允許連接:
vi /var/lib/pgsql/9.3/data/postgresql.conf
找面行:
[...]
#listen_addresses = 'localhost’
[...]
#port = 5432
[...]
兩行都取消并設(shè)置postgresql服務(wù)器IP址或設(shè)置*監(jiān)聽(tīng)所客戶(hù)端所示:
listen_addresses = '*'
port = 5432
重啟應(yīng)用更改
CentOS6.x系統(tǒng):
/etc/init.d/postgresql-9.3 restart
CentOS7系統(tǒng):
systemctl restart postgresql-9.3
9.使用phpPgAdmin管理PostgreSQL
phpPgAdmin使用PHP編寫(xiě)基于web管理工具用于管理PostgreSQL適用與PostgreSQL RPM庫(kù)
沒(méi)添加PostgreSQL庫(kù)添加EPEL庫(kù)
根據(jù)面鏈接CentOS 6.x建立EPEL庫(kù)
CentOS 7參考面鏈接
使用命令更新庫(kù)
yum update
現(xiàn)輸入命令安裝phpPgAdmin:
yum install phpPgAdmin httpd
注意phpPgAdmin區(qū)寫(xiě)要準(zhǔn)確使用面所示寫(xiě)
默認(rèn)使用訪(fǎng)問(wèn)phpPgAdmin若要遠(yuǎn)程訪(fǎng)問(wèn)需要繼續(xù):
編輯文件/etc/httpd/conf.d/phpPgAdmin.conf
vi /etc/httpd/conf.d/phpPgAdmin.conf
修改加粗部:
[...]
Alias /phpPgAdmin /usr/share/phpPgAdmin
# Apache 2.4
Require all granted
#Require host example.com
# Apache 2.2
Order deny,allow
Allow from all
# Allow from .example.com
啟或重啟Apache服務(wù)
CentOS 6.x系統(tǒng)
service httpd start
chkconfig httpd on
CentOS 7系統(tǒng)
systemctl enable httpd
systemctl start httpd
現(xiàn)打?yàn)g覽器并轉(zhuǎn)終于看面界面
使用前創(chuàng)建用戶(hù)登錄我用戶(hù)senthil密碼CentOS
能遇:Login failed
SELLinux能限制用戶(hù)連接PostgreSQL需輸入命令更改即:
setsebool -P httpd_can_network_connect_db 1
現(xiàn)應(yīng)該能登錄
采用編譯安裝 或者集安裝看看wo 網(wǎng)名能解決問(wèn)題
總結(jié)
以上是生活随笔為你收集整理的postgres 退出_centos如何退出postges?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 项目怎么部署到服务器上_项目开发学习 云
- 下一篇: 设置域名_如何设置二级域名解析?有什么设