CentOS6 use YUM to install Postgresql9.4

Source: Internet
Author: User

CentOS6 use YUM to install Postgresql9.4

PostgreSQL has been installed. The following describes how to use YUM to install postgresql in the centOS6 environment when the network is connected. (For your reference only)

(1) view the system environment

(2) First, the automatic upgrade of postgresql from yum source on centos is blocked. [Plain] view plaincopy
  1. Vim/etc/yum. repos. d/CentOS-Base.repo
Add exclude = postgresql * under [base] and [updates *. : (3) You can also obtain the postgresql rpm package and install it with rpm. : Https://yum.postgresql.org/repopackages.php (4) YUM install postgresql9.4:[SQL] view plaincopy
  1. # Yuminstallpostgresql94postgresql94-serverpostgresql94-contrib
Use this method to install postgresql. Its default path is as follows: data path:/var/lib/pgsql/9.4/data Home Directory:/usr/pgsql-9.4 (5) enter the data directory initialize postgresql Installation[SQL] view plaincopy
  1. # Sudo-upostgres/user/pgsql-9.4/bin/initdb
(6) configure the postgresql server listening address and port number[SQL] view plaincopy
  1. # Vim/var/lib/postgresql/9.4/data/postgresql. conf
  2. Listen_address = '*'
  3. Port = 5432
(7) You can set postgresql access permissions, and add the following at the end of the file:[Plain] view plaincopy
  1. # Vim/var/lib/pgsql/9.4/data/pg_hba.conf
[Plain] view plaincopy
  1. Hostallall0.0.0.00.0.0.0md5
(8) Start the postgresql service
[Plain] view plaincopy
  1. # Servicepostgresql-9.4start

(9) Modify postgresql's default postgresql database password
[Plain] view plaincopy
  1. # Sudo-upostgrespsql
  2. S = # alteruser=swithpassword 'postgres ';
[Plain] view plaincopy
  1. Or directly:
  2. Postgres = # \ passwordpostgres
(10) create databases and users, and authorize
[Plain] view plaincopy
  1. Postgres = # createuser "tuser" withpassword '000000' nocreatedb;
  2. Postgres = # createdatabase "testdb" withowner = "tuser ";
  3. Postgres = # grantallprivilegesondatabasetestdbtotuser;
(11) Use a specified user to log on to a specified database[Plain] view plaincopy
  1. # Sudo-upostgrespsql-Utuser-dtestdb-h127.0.0.1-p5432 or under the ipvs User: psql-Utuser-dtestdb-h127.0.0.1-p5432

(12) Modify postgresql database configuration for remote login
[Plain] view plaincopy
  1. # Vim/var/lib/postgresql/9.4/data/postgresql. conf
[Plain] view plaincopy
  1. A) Listening address
  2. # Change listen_addresses = 'localhost' to listen_addresses = '*'
  3. B) enable password verification
  4. # Change password_encryption = on to password_encryption = on
  5. C) accessible user ip
  6. # Vim/var/lib/pgsql/9.4/data/pg_cmd.conf add
  7. Hostallall0.0.0.00.0.0.0md5
  8. D) restart the postgresql database.
  9. # Servicepostgresql-9.4restart

(13) modify the postgresql Firewall Configuration:
[Plain] view plaincopy
  1. # Vim/etc/sysconfig/iptables Add the following content
[Plain] view plaincopy
  1. -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport5432-jACCEPT
  2. -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport80-jACCEPT
  3. # Restarting the Firewall
  4. # Sudoserviceiptablesrestart

(14) modify the postgres User Password
[Plain] view plaincopy
  1. # Sudo-passwd-upostgres
  2. # Sudo-umo-spasswd

Done. Sql9.4 is configured, and some default database options are modified. Reference: http://blog.sina.com.cn/s/blog_6af33caa0100ypck.htmlhttp://www.cnblogs.com/mchina/archive/2012/06/06/2539003.htmlhttp://www.wvser.com/archives/install-postgresql-on-fedora-centos-red-hat-rhel.htmlhttp://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html

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.