postgreSQL在linux中安装详解

postgreSQL在linux中安装详解 收藏 
这里安装8.4.4版本,首先下载postgresql-8.4.4-1-linux.bin。
http://www.postgresql.org/download/)下载linux32版本的
1.       如果该文件不在linux系统中,将其从Windows拖到linux系统中,放到任意一个目录下,最好放在/opt或者/home。推荐一个Windows文件转到linux的工具:WinSCP3

(

1、打开一个终端,su -成root用户;
2、chmod +xpostgresql-8.4.4-1-linux.bin
3、./postgresql-8.4.4-1-linux.bin //运行这个命令就可以安装软件了)

2.       [[email protected] ~]# /postgresql-8.4.1-1-linux-x64.bin – –mode text (我这里是放在了root路径下)
—————————————————————————
Welcome to the PostgreSQL Setup Wizard.

—————————————————————————
Please specify the directory where PostgreSQL will be installed.

3.       Installation Directory [/opt/PostgreSQL/8.4]: (这里直接回车,表示装在/opt目录下)
—————————————————————————

Please select a directory under which to store your data.

4.       Data Directory [/opt/PostgreSQL/8.4/data]:(这里直接回车,表示data数据装在该目录下)
—————————————————————————

Please provide a password for the database superuser (postgres). A locked Unix user account (postgres) will be created if not present.

5.       Password :[ 输入密码]

6.       Retype password :[ 重复输入]

—————————————————————————
7.       Please select the port number the server should listen on.

Port [5432]:[ 默认端口,直接回车]

[616] yi_US

[617] yi_US.utf8

[618] zh_CN

[619] zh_CN.utf8

[620] zh_HK

[621] zh_HK.utf8

[622] zh_SG

[623] zh_SG.utf8

[624] zh_TW

[625] zh_TW.euctw

[626] zh_TW.utf8

[627] zu_ZA

[628] zu_ZA.iso88591

[629] zu_ZA.utf8

Please choose an option [1] :619[ 默认字符集]

8.       Install pl/pgsql in template1 database? [Y/n]: n[是否安装模板库,这里选否]

—————————————————————————-

Setup is now ready to begin installing PostgreSQL on your computer.

9.       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.

Launch Stack Builder at exit?

10.   Stack Builder may be used to download and install additional tools, drivers and applications to complement your PostgreSQL installation. [Y/n]: y(这里是继续安装额外的工具,驱动和先关应用程序)
到这里数据库就安装成功了,然后就需要配置用户,环境变量,以及初始化数据库
11.   [[email protected] ~]# cp .bash_profile .bashrc /home/PostgreSQL/8.4/ (将文件拷到相应目录,这个是配置环境变量的)
[[email protected] ~]# chown -R postgres.postgres /home/PostgreSQL/* (将改文件的owner和group都配置为postgres)
12.   [[email protected] ~]# ls -ltr /home/PostgreSQL/8.4/.bash* (查看下是否已更改)
-rw-r–r– 1 postgres postgres 174 Nov 10 19:18 /home/PostgreSQL/8.4/.bash_profile

-rw-r–r– 1 postgres postgres 176 Nov 10 19:18 /home/PostgreSQL/8.4/.bashrc

初始化该数据库集群的缺省区域和字符集编码
13.   [[email protected] ~]#su – postgres(转到postgres用户下)
14.   [[email protected] ~]$/opt/PostgreSQL/8.4/bin/initdb –D /opt/PostgreSQL/8.4/data/(初始化数据库集群的缺省区域和字符集编码)
The files belonging to this database system will be owned by user "postgres".

This user must also own the server process.

The database cluster will be initialized with locale en_US.

The default database encoding has accordingly been set to LATIN1.

The default text search configuration will be set to "english".

fixing permissions on existing directory /home/PostgreSQL/8.4/data … ok

creating subdirectories … ok

selecting default max_connections … 100

selecting default shared_buffers … 32MB

creating configuration files … ok

creating template1 database in /home/PostgreSQL/8.4/data/base/1 … o

initializing pg_authid … ok

initializing dependencies … ok

creating system views … ok

loading system objects’ descriptions … ok

creating conversions … ok

creating dictionaries … ok

setting privileges on built-in objects … ok

creating information schema … ok

vacuuming database template1 … ok

copying template1 to template0 … ok

copying template1 to postgres … ok

WARNING: enabling "trust" authentication for local connections

You can change this by editing pg_hba.conf or using the -A option the

next time you run initdb.

Success. You can now start the database server using:

postgres -D /home/PostgreSQL/8.4/data

or

pg_ctl -D /home/PostgreSQL/8.4/data -l logfile start

恭喜你,现在就把所有的都装完了!

常用命令:
Createdb 
 创建数据库 
 
Createuser 
 创建数据库用户 
 
Dropdb 
 删除数据库 
 
Dropuser 
 删除数据库用户 
 
Psql 
 交互式PostgreSQL前端工具,可以用它来操作数据库 
 
Initdb 
 初始化postgreSQL数据库

例如:
psql  \q                               à 退出psql命令符界面
psql  \c  dbname     à 连接数据库
pg_ctl  -D /opt/PostgreSQL/8.4/data/ status         à 查看当前服务状态
pg_ctl  -D /opt/PostgreSQL/8.4/data/ start  à 启动服务
pg_ctl  -D /opt/PostgreSQL/8.4/data/ stop   à 停止服务

远程登录设置:
●打开opt/PostgreSQL/8.4/data/pg_hba.conf,像下面一样添加一行代码:(红色为添加的)
# IPv4 local connections:

host    all         all         0.0.0.0/0             md5

host    all         all         127.0.0.1/32    md5

这行代码表示所有IP地址的所有用户可以通过md5加密的方式远程登录。
●打开opt/PostgreSQL/8.4/data/postgresql.conf

按照下面的写:
listen_addresses = ‘*‘

port = 5432

max_connections = 100

这里表示监听来自所有IP的响应。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/william_zheng2010/archive/2010/07/12/5728333.aspx

时间: 2024-08-09 12:19:46

postgreSQL在linux中安装详解的相关文章

Linux中getopt详解

Linux中getopt详解 getopt函数用来解析命令行参数的,以'-'或'--'开头的参数为选项参数,选项参数除去'-'或'--'的剩下的是选项字符.如果getopt函数被重复调用,则它将会依次返回每个选项元素中的选项字符. 使用getopt需使用以下头文件: #include<unistd.h> #include<getopt.h> 有几个全局变量与getopt函数解析参数有关: optind: int型, 指示下一个要解析的参数位置,初始时为1. optarg: char

linux中iptables详解

linux中iptables详解 一.通用基础知识 1.基本概念 什么是防火墙? 所谓防火墙指的是工作于主机或网络的边缘,对于进出的报文根据事先定义的规则作检查,将那些能够被规则所匹配到的报文作出相应处理的组件. 防火墙是由软件和硬件设备组合而成.在内部网和外部网之间.专用网与公共网之间的界面上构造的保护屏障,使Internet与Intranet之间建立起一个安全网关(Security Gateway),从而保护内部网免受非法用户的侵入. 防火墙主要由服务访问规则.验证工具.包过滤和应用网关4个

linux 中/proc 详解

proc 文件系统 在Linux中有额外的机制可以为内核和内核模块将信息发送给进程-- /proc 文件系统.最初设计的目的是允许更方便的对进程信息进行访问(因此得名),现在它被每一个有有趣的东西报告的内核使用,例如/proc/modules 有模块的列表/proc/meminfo 有内存使用的统计表.  使用proc 文件系统的方法和使用设备驱动程序非常相似--创建一个/proc 文件需要的所有信息的结构,包括任何处理函数的指针(在我们的例子中只有一个,当某人试图从/proc 文件读时调用的那

Apache服务环境在Linux中搭建详解

Apache服务环境搭建详解: 本篇文章我介绍的是phpstudy集成工具,它将php.mysql及apache集成在一起,可以很方便的在不同服务环境间进行切换,比如:apache+php5.4切换为nginx+php5.4,另外,这个集成工具(windows版)提供了可视化的图形界面,以及提供了配置文件的快捷查找和网站域名的设置等,具体可到http://www.phpstudy.net网址查看详情.在这里,我介绍的是在Linux环境中怎么安装和配置apache+php+mysql(phpstu

Linux tomcat安装详解

https://blog.csdn.net/lcyaiym/article/details/76696192 https://www.cnblogs.com/hanyinglong/p/5024643.html 安装tomcat并且部署Java Web项目 http://www.cnblogs.com/hanyinglong/p/5030907.html Idea开发环境中搭建Maven并且使用Maven打包部署程序 https://www.cnblogs.com/hongwz/p/545657

Linux中inode详解,硬链接和软链接介绍

inode 详解   在Linux中,我们经常会做一些关于数据的操作(备份.传输.压缩等)或是要在后台持续的运行一些程序.由于,工作的数据量很大或者工作要持续很长的时间,我们就必须保证这个终端的启动,一旦终端关闭了,它所运行的进程也会关闭,我们所做的工作就可能前功尽弃.但是,即使我们不主动的关闭终端,终端有的时候也会应为一些原因(网络.锁屏等)而中断,导致我们的工作进度清零. 1.inode 定义 inode是用来存储文件元信息的区域.中文译名叫做"索引节点".   简单来说,inod

linux中RAID详解

一.RAID介绍 RAID即廉价冗余磁盘阵列(Redundant Array of Inexpensive Disks),从Linux 2.4内核开始,Linux就提供软件RAID,不必购买昂贵的硬件RAID控制器和附件(一般中.高挡服务器都提供这样的设备和热插拔硬盘),就可以通过并行处理多个独立的I/O 请求提高读写性能,而且能通过增加冗余信息来提高数据存储的可靠性. 二.几种RAID类型 RAID 0 非冗余,读写性能好,数据可靠性低于单个磁盘. RAID 1 镜像,读性能好,写性能与单个磁

Linux中Uboot详解

在专用的嵌入式板子运行 GNU/Linux 系统已经变得越来越流行.一个嵌入式 Linux 系统从软件的角度看通常可以分为四个层次: 1. 引导加载程序.包括固化在固件(firmware)中的 boot 代码(可选),和 Boot Loader 两大部分. 2. Linux 内核.特定于嵌入式板子的定制内核以及内核的启动参数. 3. 文件系统.包括根文件系统和建立于 Flash 内存设备之上文件系统.通常用 ram disk 来作为 root fs. 4. 用户应用程序.特定于用户的应用程序.有

Linux 中 crontab 详解及示例

cron是一个linux下的定时执行工具,可以在无需人工干预的情况下运行作业.由于Cron 是Linux的内置服务,但它不自动起来,可以用以下的方法启动.关闭这个服务: /sbin/service crond start //启动服务 /sbin/service crond stop //关闭服务 /sbin/service crond restart //重启服务 /sbin/service crond reload //重新载入配置 你也可以将这个服务在系统启动的时候自动启动: 在/etc/