Linux下PostgreSQL 的安装与配置Word格式文档下载.docx

上传人:b****3 文档编号:16366800 上传时间:2022-11-23 格式:DOCX 页数:9 大小:58.69KB
下载 相关 举报
Linux下PostgreSQL 的安装与配置Word格式文档下载.docx_第1页
第1页 / 共9页
Linux下PostgreSQL 的安装与配置Word格式文档下载.docx_第2页
第2页 / 共9页
Linux下PostgreSQL 的安装与配置Word格式文档下载.docx_第3页
第3页 / 共9页
Linux下PostgreSQL 的安装与配置Word格式文档下载.docx_第4页
第4页 / 共9页
Linux下PostgreSQL 的安装与配置Word格式文档下载.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

Linux下PostgreSQL 的安装与配置Word格式文档下载.docx

《Linux下PostgreSQL 的安装与配置Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《Linux下PostgreSQL 的安装与配置Word格式文档下载.docx(9页珍藏版)》请在冰豆网上搜索。

Linux下PostgreSQL 的安装与配置Word格式文档下载.docx

Rhel光盘里一般都为比较稳定的版本,rhev环境中所使用的数据库就是postgreSQL。

A.下载RPM包安装

B.yum安装

C.源码包安装

使用光盘的yum安装

 

[root@localhost~]#yuminstallpostgresqlpostgresql-serverpostgresql-contribpostgresql-libs

Totaldownloadsize:

6.7M

Installedsize:

31M

Isthisok[y/N]:

y

DownloadingPackages:

Installed:

postgresql.x86_640:

8.4.13-1.el6_3postgresql-contrib.x86_640:

8.4.13-1.el6_3

postgresql-libs.x86_640:

8.4.13-1.el6_3postgresql-server.x86_640:

Complete!

4.初始化PostgreSQL库

PostgreSQL服务初次启动的时候会提示初始化使用命令/etc/init.d/postgresqlinitdb初始化数据库

[root@localhost~]#/etc/init.d/postgresqlstart

/var/lib/pgsql/dataismissing.Use"

servicepostgresqlinitdb"

toinitializetheclusterfirst.

[root@localhost~]#/etc/init.d/postgresqlinitdb

Initializingdatabase:

[OK]

Youhavenewmailin/var/spool/mail/root

5.启动服务

Startingpostgresqlservice:

6.把PostgreSQL服务加入到启动列表

[root@localhost~]#chkconfigpostgresqlon

[root@localhost~]#chkconfig--list|greppostgresql

postgresql0:

off1:

off2:

on3:

on4:

on5:

on6:

off

[root@localhost~]#

7. 

修改PostgreSQL数据库用户postgres的密码(注意不是linux系统帐号)

PostgreSQL数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空,

我们需要修改为指定的密码,这里设定为’postgres’。

[root@localhost~]#su-postgres

bash-4.1$whoami

postgres

-bash-4.1$psql

psql(8.4.13)

Type"

help"

forhelp.

postgres=#ALTERUSERpostgresWITHPASSWORD'

postgres'

;

ALTERROLE

postgres=#SELECT*FROMpg_shadow;

usename|usesysid|usecreatedb|usesuper|usecatupd|passwd|valuntil|useconfig

----------+----------+-------------+----------+-----------+-------------------------------------+----------+-----------

postgres|10|t|t|t|md53175bce1d3201d16594cebf9d7eb3f9d||

(1row)

postgres=#

8.测试数据库

8.1创建测试数据库demo

postgres=#createdatabasedemo;

CREATEDATABASE

postgres=#\l

Listofdatabases

Name|Owner|Encoding|Collation|Ctype|Accessprivileges

-----------+----------+----------+-------------+-------------+-----------------------

demo|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|

postgres|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|

template0|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|=c/postgres

:

postgres=CTc/postgres

template1|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|=c/postgres

(4rows)

8.2切换到demo数据库

postgres=#\cdemo

Youarenowconnectedtodatabase"

demo"

.

8.3创建测试表test

createtabletest(idinteger,nametext);

创建droptabletest;

删除

demo=#createtabletest(idinteger,nametext);

CREATETABLE

demo=#droptabletest;

DROPTABLE

8.4插入测试数据

demo=#insertintotestvalues(1,'

demo'

);

INSERT01

demo=#

demo=#select*fromtest;

id|name

----+------

1|demo

8.5选择数据

数据库创建测试成功。

9. 

修改linux系统用户postgres的密码

PostgreSQL数据库默认会创建一个linux系统用户postgres,通过passwd命令设置系统用户的密码为post123。

[root@localhost~]#passwdpostgres

Changingpasswordforuserpostgres.

Newpassword:

BADPASSWORD:

itistoosimplistic/systematic

Retypenewpassword:

passwd:

allauthenticationtokensupdatedsuccessfully.

10. 

修改PostgresSQL数据库配置实现远程访问

10.1修改postgresql.conf文件

[root@localhost~]#vi/var/lib/pgsql/data/postgresql.conf

如果想让PostgreSQL监听整个网络的话,将listen_addresses前的#去掉,并将listen_addresses='

localhost'

改成listen_addresses='

*'

listen_addresses='

#whatIPaddress(es)tolistenon;

#comma-separatedlistofaddresses;

#defaultsto'

'

=all

#(changerequiresrestart)

10.2修改客户端认证配置文件pg_hba.conf

将需要远程访问数据库的IP地址或地址段加入该文件。

#IPv4localconnections:

hostallall127.0.0.1/32ident

hostallall192.168.66.0/24md5

[root@localhost~]#vi/var/lib/pgsql/data/pg_hba.conf

[root@localhost~]#/etc/init.d/postgresqlrestart

Stoppingpostgresqlservice:

11.重启服务以使设置生效

12.远程测试连接

pgadmin是一个设计,维护和管理Postgres数据库用的通用工具。

它能在各种平台的Windows,Linux,FreeBSD,Mac和Solaris服务器上使用。

可以从www.pgadmin.org下载。

密码为postgres

测试成功可以通过这个工具操作postgres数据库

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 动物植物

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1