3gipnet 发表于 2016-11-19 07:26:31

postgresql yum安装和配置

  centos用yum安装postgresql的路径为 /var/lib/pgsql/中。
  1.安装postgresql9.0 yum 仓库
  rpm -i http://yum.postgresql.org/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');

  至上,安装成功。
  refurl:http://wandejun1012.iyunv.com/admin/blogs/2005595
  -----------------------------------------------------------
  ps:1.可以通过查找pg_hba.conf,来定位postgresql的位置。
  2.重启postgresql,可以用service postgresql restart
页: [1]
查看完整版本: postgresql yum安装和配置