Home > Database > Mysql Tutorial > body text

在Linux下使用源代码安装PostgreSQL步骤

WBOY
Release: 2016-06-07 16:52:40
Original
1183 people have browsed it

本文详细介绍在Red Hat Enterprise Linux Server 5上使用源代码安装PostgreSQL8.3.3数据库的步骤,使用root用户进行安装。1.下载P

本文详细介绍在Red Hat Enterprise Linux Server 5上使用源代码安装PostgreSQL8.3.3数据库的步骤,使用root用户进行安装。

1.下载PostgreSQL8.3.3的Linux平台对应的源代码包,可以到PostgreSQL的官方网站:上下载。如下所示的为下载在本地计算机上的源码包文件:

postgresql-8.3.3.tar.gz

2.使用gzip命令和tar命令将源代码包进行解压缩,,执行如下命令:

gzip -d postgresql-8.3.3.tar.gz

执行gzip命令之后,将把源码包解压缩,得到postgresql-8.3.3.tar文件。

tar xvf postgresql-8.3.3.tar

3.执行如下的命令:

cd postgresql-8.3.3

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

make

make install

第一条命令是进入postgresql源代码文件的根目录,然后第二条命令执行configure,会在源代码根目录中产生Makefile文件,第三和第四个命令分别是执行make对源代码进行编译和安装。

4.接下来在系统中添加postgres用户,分别执行如下命令进行设置:

useradd postgres ---- 添加postgres用户

passwd postgres ---- 重置postgres用户的系统登录密码,根据提示操作

mkdir /usr/local/pgsql/data ---- 创建data目录,次目录可根据需要更改

chown postgres /usr/local/pgsql/data ---- 将data目录的所有者更改为postgres

su - postgres ---- 切换到postgres用户执行下面的命令

5.接下来初始化并启动数据库服务器,使用postgres用户执行下面的命令:

/usr/local/pgsql/bin/initdb -D mkdir /usr/local/pgsql/data -- 初始化数据库

/usr/local/pgsql/bin/postmaster -D mkdir /usr/local/pgsql/data -- 启动数据库服务器。

至此,PostgreSQL8.3.3数据库便在Red Hat Linux中安装完成了。此时可使用pgsql -U postgres命令来连接数据库了。

如果想让PostgreSQL数据库服务器随操作系统的启动而启动,可以将启动脚本拷贝到/etc/init.d/目录下,具体执行如下命令:

cp postgresql8.3.3/contrib/start-scripts/linux /etc/init.d/postgresql

chmod +x postgresql 

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!