匿名用户
1级
2016-04-11 回答
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)环境变量
postgres@campost:~> 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
postgres@campost:~> . .profile
配置如上环境表里之后,可以使用psql连接数据库:
postgres@campost:/opt/PostgreSQL/9.1/data> 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
重启数据库:
postgres@campost:~> pg_ctl restart
waiting for server to shut down.... done
server stopped
server starting
此时可以用PgAdmin远程登录postgres用户了,此时只有一个库postgres。