Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6322095
  • 博文数量: 2759
  • 博客积分: 1021
  • 博客等级: 中士
  • 技术积分: 4091
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-11 14:14
文章分类

全部博文(2759)

文章存档

2019年(1)

2017年(84)

2016年(196)

2015年(204)

2014年(636)

2013年(1176)

2012年(463)

分类: Mysql/postgreSQL

2013-04-02 08:43:36

原文地址:linux下安装PostgreSQL 作者:Junn9527

OS:suselinux11(64bit)
PostgreSQL:PostgreSQL9.1(64bit)
1、建用户及目录

linux:/home # groupadd postgres
linux:/home # useradd postgres -g postgres
linux:/home # mkdir /home/postgres
linux:/home # chown postgres:postgres /home/postgres
linux:/home # passwd postgres
2、用root运行安装(不能以postgres运行安装)
linux:/opt # mkdir /opt/PostgreSQL
linux:/opt # chown postgres:postgres /opt/PostgreSQL
linux:/opt/PostgreSQL # chmod +x postgresql-9.1.1-1-linux-x64.bin
linux:/opt/PostgreSQL # ./postgresql-9.1.1-1-linux-x64.bin
----------------------------------------------------------------------------
Welcome to the PostgreSQL Setup Wizard.
----------------------------------------------------------------------------
Please specify the directory where PostgreSQL will be installed.
Installation Directory [/opt/PostgreSQL/9.1]:
----------------------------------------------------------------------------
Please select a directory under which to store your data.
Data Directory [/opt/PostgreSQL/9.1/data]:
----------------------------------------------------------------------------
Please provide a password for the database superuser (postgres). A locked Unix
user account (postgres) will be created if not present.
Password :
Retype password :
----------------------------------------------------------------------------
Please select the port number the server should listen on.
Port [5432]:
----------------------------------------------------------------------------
Advanced Options
Select the locale to be used by the new database cluster.
Locale
[1] [Default locale]
[2] C
[3] POSIX
...
[441] zu_ZA
[442] zu_ZA.utf8
Please choose an option [1] :
----------------------------------------------------------------------------
Setup is now ready to begin installing PostgreSQL on your computer.
Do you want to continue? [Y/n]: y
----------------------------------------------------------------------------
Please wait while Setup installs PostgreSQL on your computer.
  Installing
 0% ______________ 50% ______________ 100%
 ########################################
----------------------------------------------------------------------------
Setup has finished installing PostgreSQL on your computer.
3、相关配置
(1)环境变量
:~> vi .profile(new file)
export PGSQL_HOME=/opt/PostgreSQL/9.1
export PATH=$PGSQL_HOME/bin:$PATH
#export PGDATAS=$PGSQL_HOME/datas
export PGDATA=$PGSQL_HOME/data
export PGDATABASE=postgres
export PGUSER=postgres
#export PGPORT=1234
export PGLOCALEDIR=$PGSQL_HOME/share/locale
export MANPATH=$MANPATH:$PGSQL_HOME/share/man
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGSQL_HOME/lib
:~> . .profile
配置如上环境表里之后,可以使用psql连接数据库:
> psql
Password:
psql.bin (9.1.1)
Type "help" for help.
postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
postgres=#
(2)网络配置
加网络信任关系:
----详细信息请参考PostgreSQL document,20.1. pg_hba.conf 文件
vi /opt/PostgreSQL/9.1/data/pg_hba.conf
添加一行:host    all         all                           trust
重启数据库:
:~> pg_ctl restart
waiting for server to shut down.... done
server stopped
server starting
此时可以用PgAdmin远程登录postgres用户了,此时只有一个库postgres。
阅读(749) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~