日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

postgres 退出_centos如何退出postges?

發(fā)布時間:2025/3/20 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 postgres 退出_centos如何退出postges? 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

PostgreSQL強源象關系類型數據庫系統(tǒng)能運行于幾乎所主要操作系統(tǒng)包括Linux、Unix(AIX、BSD、HP-UX、SGI

IRIX、Mac OS、Solaris、Tru64)、Windows OS篇教程我習何CentOS7/6.5/6.4 server

建立PostgreSQL

1.安裝PostgreSQL

首先根據服務器架構添加PostgreSQL庫:

CentOS 6.x 32bit:

rpm -Uvh 1.noarch.rpm

CentOS 6.x 64bit:

rpm -Uvh

CentOS 7 64bit:

rpm -Uvh

于其發(fā)行版查看鏈接并建立庫:

使用命令更新庫:

yum update

使用命令安裝PostgreSQL:

yum install postgresql93-server postgresql93-contrib

使用命令初始化PostgreSQL數據庫:

CentOS 6.x 系統(tǒng):

service postgresql-9.3 initdb

CentOS 7系統(tǒng):

/usr/pgsql-9.3/bin/postgresql93-setup initdb

啟PostgreSQL服務并使機自啟:

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.調整Iptables/Firewall

接調整防火墻站規(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服務:

service iptables restart

CentOS系統(tǒng):

firewall-cmd --permanent –add-port=5432/tcp

firewall-cmd --permanent –add-port=80/tcp

firewall-cmd --reload

3.訪問PostgreSQL用命令提示符

默認情況數據庫名用戶名都postgres切換至用戶執(zhí)行相關操作:

su – postgres

輸入命令登陸:

psql

例輸:

psql (9.3.5)

Type "help" for help.

Postgres=#

通輸入\q退postgresql返命令終端:

4.設置用戶密碼

登陸至postgres命令提示符界面

su – postgres

psql

使用命令設置密碼

postgres=# \password postgres

Enter new password:

Enter it again:

postgres=# \q

輸入命令建立PostgreSQL系統(tǒng)管理工具

postgres=# CREATE EXTENSION adminpack;

CREATE EXTENSION

5.創(chuàng)建用戶數據庫

例:用戶名:senthil 密碼:centos 數據庫名:mydb

轉postgres用戶

su – postgres

創(chuàng)建用戶senthil

$ createuser senthil

創(chuàng)建數據庫

$ createdb mydb

現(xiàn)登陸至psql提示符界面用戶senthil設置密碼及授權數據庫mydb訪問:

$ 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.刪除用戶數據庫

首先轉postgres界面

su – postgres

輸入命令

$ dropdb

刪除用戶名輸入

$ dropuser

7.配置PostgreSQL-MD5認證

MD5認證需要客戶端提供MD5-encrypted 密碼便身份驗證需要編輯 /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服務應用更改

CentOS 6.x系統(tǒng)

service postgresql-9.3 restart

CentOS 7系統(tǒng)

systemctl restart postgresql-9.3

8.配置PostgreSQL-Configure TCP/IP

默認情況TCP/IP連接行所其計算機用戶能連接postgresql編輯文件 /var/lib/pgsql/9.3/data/postgresql.conf允許連接:

vi /var/lib/pgsql/9.3/data/postgresql.conf

找面行:

[...]

#listen_addresses = 'localhost’

[...]

#port = 5432

[...]

兩行都取消并設置postgresql服務器IP址或設置*監(jiān)聽所客戶端所示:

listen_addresses = '*'

port = 5432

重啟應用更改

CentOS6.x系統(tǒng):

/etc/init.d/postgresql-9.3 restart

CentOS7系統(tǒng):

systemctl restart postgresql-9.3

9.使用phpPgAdmin管理PostgreSQL

phpPgAdmin使用PHP編寫基于web管理工具用于管理PostgreSQL適用與PostgreSQL RPM庫

沒添加PostgreSQL庫添加EPEL庫

根據面鏈接CentOS 6.x建立EPEL庫

CentOS 7參考面鏈接

使用命令更新庫

yum update

現(xiàn)輸入命令安裝phpPgAdmin:

yum install phpPgAdmin httpd

注意phpPgAdmin區(qū)寫要準確使用面所示寫

默認使用訪問phpPgAdmin若要遠程訪問需要繼續(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服務

CentOS 6.x系統(tǒng)

service httpd start

chkconfig httpd on

CentOS 7系統(tǒng)

systemctl enable httpd

systemctl start httpd

現(xiàn)打瀏覽器并轉終于看面界面

使用前創(chuàng)建用戶登錄我用戶senthil密碼CentOS

能遇:Login failed

SELLinux能限制用戶連接PostgreSQL需輸入命令更改即:

setsebool -P httpd_can_network_connect_db 1

現(xiàn)應該能登錄

采用編譯安裝 或者集安裝看看wo 網名能解決問題

總結

以上是生活随笔為你收集整理的postgres 退出_centos如何退出postges?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。