Install PostgreSQL using source code in Linux

Source: Internet
Author: User

This article describes how to install the PostgreSQL8.3.3 database with the source code on Red Hat Enterprise Linux Server 5 and install it with the root user.

1. Download the source code package corresponding to PostgreSQL8.3.3 on the Linux platform. You can download it from the official PostgreSQL website www.postgresql.org. The following is the source code package file downloaded on the local computer:

Postgresql-8.3.3.tar.gz

2. decompress the source code package using the gzip and tar commands and execute the following command:

Gzip-d postgresql-8.3.3.tar.gz

After the gzipcommand is executed, the source code package will be decompressed to the postgresql-8.3.3.tar file.

Tar xvf postgresql-8.3.3.tar

3. Execute the following command:

Cd postgresql-8.3.3

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

Make

Make install

The first command is to enter the root directory of the postgresql source code file, and then the second command runs configure to generate the Makefile file in the source code root directory, the third and fourth commands are to execute make to compile and install the source code.

4. Add the postgres user to the system and execute the following commands to set the user:

Useradd postgres ---- add postgres user

Passwd postgres ---- reset the logon password of postgres, and follow the prompts.

Mkdir/usr/local/pgsql/data ---- create a data directory, which can be changed as needed

Chown postgres/usr/local/pgsql/data ---- change the owner of the data directory to postgres

Su-ipvs ---- switch to ipvs and run the following command.

5. initialize and start the database server. Run the following command using S:

/Usr/local/pgsql/bin/initdb-D mkdir/usr/local/pgsql/data -- initialize the database

/Usr/local/pgsql/bin/postmaster-D mkdir/usr/local/pgsql/data -- start the database server.

So far, the PostgreSQL8.3.3 database has been installed in Red Hat Linux. You can use the pgsql-U postgres command to connect to the database.

If you want the PostgreSQL database server to start with the operating system, you can copy the startup script to the/etc/init. d/directory and execute the following command:

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

Chmod + x postgresql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.