Installation and configuration of Postgresql in Linux and C Application

Source: Internet
Author: User
The former is the management terminal installation package in windows, and the latter is the source code installation package of the database. (2) Copy postgresql-8.2.3.tar.gz to a temporary directory in Linux.

The former is the management terminal installation package in windows, and the latter is the source code installation package of the database. (2) Copy postgresql-8.2.3.tar.gz to a temporary directory in Linux.

(1zip download pgadmin3-1.6.2.zip and postgresql-8.2.3.tar.gz from

The former is the management terminal installation package in windows, and the latter is the source code installation package of the database.

(2gz copy postgresql-8.2.3.tar.gz to a temporary directory in Linux, decompress

Tar-zxvf postgresql-8.2.3.tar.gz

Then go to the decompressed directory,

Cd postgresql-8.2.3

Install and configure:

#./Configure

In this way, the database will be installed in the default location/usr/local/pgsql /.

# Gmake

If there is no problem, we can see the last prompt message.

"All of PostgreSQL successfully made. Ready to install ."

# Gmake install

After successful installation, the last prompt message "PostgreSQL installation complete." is displayed ."

Cd/usr/local/

Ls

We can see that the pgsql directory contains the installed package.

(3) environment settings after installation:

Add User Group:

# Groupadd postgresql

# Useradd-g postgresql

At this time, the postgresql directory has been generated under the/home directory, and then environment variables and profile

Modify

# Cd/home/postgresql

# Vi. bash_profile

Add at the end of the file

Export PATH = $ PATH:/usr/local/pgsql/bin

Export MANPATH = $ MANPATH:/usr/local/pgsql/man

Export LD_LIBRARYPATH = $ LD_LIBRARYPATH:/usr/local/pgsql/lib

Save and exit.

Create Database directory and log directory

Mkdir/usr/local/pgsql/data

Mkdir/usr/local/pgsql/log

Touch/usr/local/pgsql/log/pgsql. log

Change owner:

Chown-R postgresql: postgresql/usr/local/pgsql/data

Chown-R postgresql: postgresql/usr/local/pgsql/log

Chown-R postgresql: postgresql/usr/local/pgsql/log/pgsql. log

(4): Initialize the database and create a database and a user

Su-postgresql

Initdb-D/usr/local/pgsql/data

Now you can start the database.

# Pg_ctl-D/usr/local/pgsql/data-l/usr/local/pgsql/log/pgsql. log start

"Server starting" prompt"

Then we run the process to check whether the service has been started:

[Postgresql @ localhost ~] $ Ps-A | grep postgres

19932 pts/1 00:00:00 ipvs

19934? 00:00:00 postgres

19935? 00:00:00 postgres

Indicates that the database service has been started.

Create a database

[Postgresql @ localhost ~] $ Createdb psmp

Prompt "create database"

Create user

[Postgresql @ localhost ~] $ Createuser-sADEP psmpAdmin

Enter password for new role:

Enter it again:

Shall the new role be allowed to create more new roles? (Y/n) y

Prompt "create role"

-S indicates the superuser.

We set the password to psmpPass.

Access Database

[Postgresql @ localhost ~] $ Psql-d psmp-U psmpAdmin

Then you can run SQL statements, such as select or insert.

(5): Install pgadmin1.6.2 on windows, that is, the first package to decompress the EXE program. This is relatively simple.

After padmin is installed, you may be eager to use this management tool to connect to the back-end database. However, you will encounter connection failure because there are some other things to be configured.

Cd/usr/local/pgsql/data/directory

You can see that two files need to be modified: pg_mirror.conf and postgresql. conf.

Modify listen_address In the postgresql. conf file to "*" and remove the # prefix. For some versions

Database. For example, if I use 7.4.16, I only need to remove tcpip_socket = true and port = 5432.

The prefix of the watch character, okay, save; modify the pg_assist.conf file, in

# IPv4-style local connections:

Host all 127.0.0.1 255.255.255.255 trust

Add a row below

Host all 192.168.1.3 255.255.0.0 trust

Assume that the IP address of your windows system is 192.168.1.3.

Then, pg_ctl-D/usr/local/pgsql/data reload is used to re-load the configuration.

Then you can connect to pgadmin.

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.