[Reprint]centos6.3 installation start using PostgreSQL 9.2

Source: Internet
Author: User
Tags psql

----------------------------------------------installation-----------------------------------------------------

The installation section mainly refer to this article:

Http://www.cnblogs.com/shanyou/archive/2012/08/25/2656783.html

1. Visit http://yum.pgrpms.org/reporpms/repoview/letter_p.group.html first to find the right version.

2. Rpm,wget down, or win down and then upload to Linux.

# wget yum.pgrpms.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm

3. # RPM-IVH pgdg-centos92-9.2-6.noarch.rpm

4. Install or upgrade Postgresql-libs

# Yum Upgrade Postgresql-libs

5. # yum-y Install Postgresql92-server

The final output is

Dependency installed:
postgresql92.x86_64 0:9.2.4-1pgdg.rhel6 postgresql92-libs.x86_64 0:9.2.4-1pgdg.rhel6

complete!

The instructions are done.

----------------------------------------------Start-----------------------------------------------------

You can see that the directory was created:/VAR/LIB/PGSQL/9.2/

# LS/VAR/LIB/PGSQL/9.2/

Backups data

1. Initialization

[Email protected] data]# service postgresql-9.2 Initdb
Initializing database: [OK]

After initialization, there are many files in the data directory without files.

[[email protected] data]# ls
Base pg_hba.conf pg_multixact pg_snapshots pg_tblspc pg_xlog
Global pg_ident.conf pg_notify pg_stat_tmp pg_twophase postgresql.conf
Pg_clog pg_log pg_serial Pg_subtrans pg_version

Created a user postgres, which may have been created at the time of installation, and did not notice when it was created.

[Email protected] bin]# tail-1/etc/passwd
Postgres:x:26:26:postgresql Server:/var/lib/pgsql:/bin/bash

2. Start

[[Email protected] data]# service postgresql-9.2 start
Starting postgresql-9.2 service: [OK]

[Email protected] ~]#/etc/init.d/postgresql-9.2 status
(PID 13411) is running ...

The start is over.

---------------------------------------------------Use------------------------------------------------------

1. Need to find the bin directory of Postgres before use

Have not found this before, and then see the online posts are said in /usr/local/pgsql/bin/createdb this place, and then find a half-day, did not find. So I find a bit.

[Email protected] bin]# Find/-name createdb
/usr/pgsql-9.2/bin/createdb
/usr/bin/createdb

Obviously, it's under the/usr/pgsql-9.2/bin directory.

2. Add to/etc/profile inside

# Vi/etc/profile

At the bottom, add the following:

Pgdata=/var/lib/pgsql/9.2/data
Export PGDATA
Path= $PATH: $HOME/bin:/usr/pgsql-9.2/bin
Export PATH

Save exit.

# Source/etc/profile

Make it effective.

3. Modify the Postgres password

# passwd Postgres

4. Switch users

[email protected] bin]# su postgres
bash-4.1$

5. You can use it later.

bash-4.1$ Psql
Psql (9.2.4)
Type ' help ' for help.

postgres=#

PostgreSQL Basic Command http://www.360doc.com/content/10/0829/11/1422459_49598577.shtml
PostgreSQL 8.0 Chinese Manual http://man.ddvip.com/database/PostgreSQL80zhref/

Note: If you enter a command, the following prompt appears:

Could not change directory to "/root"

Instructions when you enter the command folder, is under/root, $ CD, switch to your own folder just fine.

----------------------------------------Remote Access--------------------------------------------------------

Main reference: http://blog.csdn.net/ivan820819/article/details/4216522

Http://www.cnblogs.com/hiloves/archive/2011/08/20/2147043.html

Remote access, the main set of two files, are in the/var/lib/pgsql/9.2/data directory.

One is postgresql.conf, one is pg_hba.conf.

Under Postgresql.conf, just set to: listen_addresses = ' * '

Under Pg_hba.conf, add at the bottom:

Host All 0.0.0.0/0 Trust

I compare the various unrestricted moral integrity, if need limit, see above reference, or file comment.

Then reboot/etc/init.d/postgresql restart

If you want to remotely access under win, you need to install Pgadmin.

Website: Http://www.pgadmin.org/download/windows.php?lang=zh_CN

Download it and install it, then add the host address.

For the use of pgadmin, you can see:

Http://wenku.baidu.com/view/2897cda4b0717fd5360cdc6a.html

For data import and export, you can see:

Http://www.postgresql.org/docs/7.4/static/app-pgdump.html

Http://www.postgresql.org/docs/7.4/static/app-pgrestore.html

--------------------------------------End-------------------------------------------------------------

[Reprint]centos6.3 installation start using PostgreSQL 9.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.