数据库

 首页 > 数据库 > postgresql > 在Linux系统安装postgresql数据库的步骤

在Linux系统安装postgresql数据库的步骤

分享到:
【字体:
导读:
         摘要:mysql是一条轻快的小海豚,但是缺少很多现代关系数据库应有的特色,例如:引用完整性,视图,触发器等。因此,如果你需要开发一个电子商务的网站,需要这些功能的话,你或许应该考虑postgresql了。本文将通过其在redhat7.1上安装过程,简要介绍其用法。...

在Linux系统安装postgresql数据库的步骤

  mysql 是一条轻快的小海豚,但是缺少很多现代关系数据库应有的特色,例如:引用完整性,视图,触发器等。因此,如果你需要开发一个电子商务的网站,需要这些功能的话,你或许应该考虑 postgresql 了。本文将通过其在 red hat 7.1 上安装过程,简要介绍其用法。

  postgresql 的官方下载地址为:

  ftp://ftp.postgresql.org/pub/v7.1.3/postgresql-7.1.3.tar.gz

  http://www.postgresql.org/

  如果下载最新的开发版本,你需要下载并安装 flex(版本号大于 2.5.4) 以及 bison (版本号大于 1.28)

  设计人员为了安全考虑,postgresql 不能以 root 用户运行,所以必须建立对应的用户和组。

  # useradd postgre (自动建立 postgre 组)

  安装的过程并不复杂和其他源码版本的安装方法类似:

  解压到 /usr/local/src:

  # tar xvfz postgresql-7.1.3.tar.gz

  # cd postgresql-7.1.3

  # ./configure --prefix=/usr/local/pgsql

  # make

  # make install

  # chown -r postgre.postgre /usr/local/pgsql

  这样安装完毕后,并不是万事大吉了,还有一些收尾工作要做:

  # vi ~postgre/.bash_profile

  添加:

  pglib=/usr/local/pgsql/lib

  pgdata=$home/data

  path=$path:/usr/local/pgsql/bin

  manpath=$manpath:/usr/local/pgsql/man

  export pglib pgdata path manpath

  以 postgres 用户登录,

  # su - postgre

  建立数据库目录:

  $ mkdir data

  启动数据库引擎:

  $ initdb

  [postgre@www postgre]$ initdb

  this database system will be initialized with username "postgre".

  this user will own all the data files and must also own the server process.

  fixing permissions on pre-existing data directory /home/postgre/data

  creating database system directory /home/postgre/data/base

  creating database xlog directory /home/postgre/data/pg_xlog

  creating template database in /home/postgre/data/base/template1

  creating global relations in /home/postgre/data/base

  adding template1 database to pg_database

  creating view pg_user.

  creating view pg_rules.

  creating view pg_views.

  creating view pg_tables.

  creating view pg_indexes.

  loading pg_description.

  vacuuming database.

  success. you can now start the database server using:

  /usr/local/pgsql/bin/postmaster -d /home/postgre/data

  or

  /usr/local/pgsql/bin/pg_ctl -d /home/postgre/data start

  $ postmaster -i -d ~/data &

  [1] 22603

  [postgre@www postgre]$ debug: data base system is starting up at thu jan 31 02:00:44 2002

  debug: data base system was shut down at thu jan 31 01:57:58 2002

  debug: data base system is in production state at thu jan 31 02:00:44 2002

  这样 postgresql 使用位于 /usr/local/pgsql/data 的数据库,允许 internet 用户的连接( -i ) ,并在后台运行。

  建立数据库

  $createdb mydb

  postgresql 会返回 “ created database”的信息,表明数据库建立完成。

  $psql mydb

  进入交互 psql 工具,建立表:

  create table mytable (

  id varchar(20),

  name varchar(30));

  建立完成后,会得到一条 “created” 的信息,表示建立成功。现在插入一条数据:

  insert into mytable values('author', 'xu yongjiu');

  psql 返回 insert 18732 1,查询插入是否成功:

  select * from mytable;

  退出 psql ,用 q 命令。

在Linux系统安装postgresql数据库的步骤
分享到:
在Linux系统下安装PostgreSQL数据库
在Linux系统下安装PostgreSQL数据库 从网上找到了很多,过程大都差不多,但很容易让一些初学者不知所云。这里对我在Fedora 3上安装PostgreSQL 8.4.4的过程做了简单整理,希望对刚入门的新手们有所帮助。 首先要下载PostgreSQL安装包postgresql-8.4.4.tar.gz,下载地址为: ftp://ftp2.cn.postgresql.org/postgresql/...
如何用RAMDISK来提高PostgreSQL访问速度
如何用RAMDISK来提高PostgreSQL访问速度 这篇论坛文章(赛迪网)主要介绍了使用RAMDISK提高PostgreSQL访问速度的具体方法,详细内容请参考下文。 RAMDISK作用于硬盘空间的内存。无论什么时候你使用RAMDISK,实际上你是在使用内存而不是硬盘。在这一点上既有优点又有缺点。最基本的,最大的优点是你是在使用内...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……