PostgreSQL centos6.5 installation and common commands

Source: Internet
Author: User
Tags postgresql psql

Today, install the PostgreSQL database under centos6.5, and now tidy up your own procedures.

I. Installation of postgresql9.4 under Centos6.5

1.1. Display all the relevant PostgreSQL installation packages

Yum List postgres*

1.2. Install the database

Yum Install Postgresql94-server
1.2. Initializing the database (initializing the database default path in/var/lib/pgsql/9.4/data)
Service Install postgresql-9.4 Initdb
1.3. Start the service
Service postgresql9.4 Start

Two. PostgreSQL Database password settings

2.1. Switch user to Postgres

Su-postgres

2.2. Connect to the database

Psql-u Postgres

3.3. Set a password for the user name

\password Postgres (Set password)

Alter user postgres with password ' 123456 ' (modified)

3.4. Modify the default authentication method (important)

    

In/var/lib/pgsql/data/pg_hba.conf, the default validation method

        Host all 127.0.0.1/32 ident

Change to password verification

Host All 127.0.0.1/32 MD5

3.5. Restart the database

Systemctl Restart PostgreSQL

3.6. New User Login

Psql-u postgres-h 127.0.0.1

Four. Database import and Export command

4.1. Backup

      To back up the database:
-bash-3.2$ pg_dump Music >/tmp/music.dmp

To view the backup:

-bash-3.2$ cd/tmp/
-bash-3.2$ ls

4.2. Import

Psql-u postgres (user name)  database name (default is the same as user name) </data/dum.sql

PostgreSQL centos6.5 installation and common commands

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.