CentOS 6.5 Installation and configuration PostgreSQL9.2

Source: Internet
Author: User
Tags postgresql psql

Reference: http://www.cnblogs.com/mchina/archive/2012/06/06/2539003.html

1. Use Yum installation test here

Use PostgreSQL Yum Repository to install the latest version of PostgreSQL.

[Email protected] ~]# rpm-i http://download.postgresql.org/pub/repos/yum/9.2/redhat/rhel-6.5-x86_64/ pgdg-redhat92-9.2-8.noarch.rpm

[email protected] ~]# Yum install postgresql92-server Postgresql92-contrib

[[email protected] ~]# Rpm-qa |grep PostgreSQL View Installation

[[email protected] ~]# useradd postgres Create a startup user

[[email protected] ~]#/etc/init.d/postgresql-9.2 Initdb Initialize and start the database

[[email protected] ~]# su-postgres Switch User

[[email protected] ~]$ psql-l view table

Repository List

name | Owned by | Character Encoding | Proofing Rules | Ctype | Access permissions

-----------+----------+----------+-------------+-------------+-----------------------

Postgres | Postgres | UTF8 | Zh_cn. UTF-8 | Zh_cn. UTF-8 |

Template0 | Postgres | UTF8 | Zh_cn. UTF-8 | Zh_cn. UTF-8 | =c/postgres +

| | | | | Postgres=ctc/postgres

template1 | Postgres | UTF8 | Zh_cn. UTF-8 | Zh_cn. UTF-8 | =c/postgres +

| | | | | Postgres=ctc/postgres

(3 line Records)

2. Create a database and authorize

Reference: https://www.2cto.com/database/201708/671319.html

[[email protected] ~]$ Psql Login

Psql (9.2.24)

Enter "Help" for information.

postgres=# alter user postgres with password ' postgres '; Modify the Postgre password

postgres=# CREATE DATABASE Sina OWNER postgres; Creating Database hints: Create databases

postgres=# GRANT all privileges on the DATABASE Sina to Postgres; Authorization Success prompt: Grant

postgres=# \q Exit

[Email protected] ~]$

[[email protected] ~]$ psql-u postgres-d sina-h 127.0.0.1-p 5432 Login Test

Password for user postgres:

Psql (9.2.24)

Enter "Help" for information.

sina=# \l

3. Open Remote connection:

Reference: http://www.cnblogs.com/jevonsea/archive/2013/01/24/2874184.html

Modify 2 configuration Files

[Email protected] ~]# vim/var/lib/pgsql/9.2/data/postgresql.conf

Set the value of the Listen_addresses key in the file to "*".

[Email protected] ~]# vim/var/lib/pgsql/9.2/data/pg_hba.conf

Add the following configuration under the host all All 127.0.0.1/32 MD5 line of the configuration file, or modify the line directly to the following configuration

Host All 0.0.0.0/0 MD5

If you do not want to allow all IP remote access, you can set the 0.0.0.0 in the above configuration item to a specific IP value.

4, the basic construction database to build the table operation

Reference: http://www.yiibai.com/html/postgresql/2013/080439.html

The basic syntax for creating a table statement is as follows:

CREATE TABLE DEPARTMENT (ID int PRIMARY KEY NOT NULL, DEPT CHAR (a) not NULL, EMP_ID int. NOT NULL);

CentOS 6.5 Installation and configuration PostgreSQL9.2

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.