咨询热线:4006-75-4006

售前:9:00-23:30    备案:9:00-18:00    技术:7*24h

Linux下postgresql yum安装和配置

2016-12-08 16:51:00 9878次

centos用yum安装postgresql的路径为 /var/lib/pgsql/中。

 

 

1.安装postgresql9.0 yum 仓库

 

rpm -i http://www.landui.com/9.2/redhat/rhel-6-x86_64/pgdg-redhat92-9.2-7.noarch.rpm

 

2.安装新版本的Postgresql

yum install postgresql92-server postgresql92-contrib

 

3.初始化数据库

/etc/init.d/postgresql-9.2 initdb

 

4.启动数据库

/etc/init.d/postgresql-9.2 start

 

注意:postgresql启动后就可以利用service postgresql-9.2 start/restart/stop来控制它了。

虽然打完service后,按p不提示postgresql-9.2,但是可以用手输。

 

5.把postgresql加入自启动列表

cd /etc/init.d

chkconfig --add postgresql9.2

 

6.查看一下自启动列表

chkconfig --list

在这里可以看到postgresql已经在其中了。

 

 

7.PostgreSQL 数据库默认会创建一个postgres的数据库用户作为数据库的管理员,默认密码为空,我们需要修改为指定的密码,这里设定为’postgres’

 

 直接在控制台输入以下命令:

# su - postgres

$ psql

# ALTER USER postgres WITH PASSWORD 'postgres';
# select * from pg_shadow ;

 

 

# create database david;

 

# c david

 

david=# create table test (id integer, name text);

david=insert into test values (1,'david');

 

 

至上,安装成功。

 -----------------------------------------------------------

ps:1.可以通过查找pg_hba.conf,来定位postgresql的位置。

2.重启postgresql,可以用service postgresql restart



首页
最新活动
个人中心