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
- 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
- # 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
- # Sudo-upostgres/user/pgsql-9.4/bin/initdb
(6) configure the postgresql server listening address and port number[SQL] view plaincopy
- # Vim/var/lib/postgresql/9.4/data/postgresql. conf
- Listen_address = '*'
- Port = 5432
(7) You can set postgresql access permissions, and add the following at the end of the file:[Plain] view plaincopy
- # Vim/var/lib/pgsql/9.4/data/pg_hba.conf
[Plain] view plaincopy
- Hostallall0.0.0.00.0.0.0md5
(8) Start the postgresql service
[Plain] view plaincopy
- # Servicepostgresql-9.4start
(9) Modify postgresql's default postgresql database password
[Plain] view plaincopy
- # Sudo-upostgrespsql
- S = # alteruser=swithpassword 'postgres ';
[Plain] view plaincopy
- Or directly:
- Postgres = # \ passwordpostgres
(10) create databases and users, and authorize
[Plain] view plaincopy
- Postgres = # createuser "tuser" withpassword '000000' nocreatedb;
- Postgres = # createdatabase "testdb" withowner = "tuser ";
- Postgres = # grantallprivilegesondatabasetestdbtotuser;
(11) Use a specified user to log on to a specified database[Plain] view plaincopy
- # 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
- # Vim/var/lib/postgresql/9.4/data/postgresql. conf
[Plain] view plaincopy
- A) Listening address
- # Change listen_addresses = 'localhost' to listen_addresses = '*'
- B) enable password verification
- # Change password_encryption = on to password_encryption = on
- C) accessible user ip
- # Vim/var/lib/pgsql/9.4/data/pg_cmd.conf add
- Hostallall0.0.0.00.0.0.0md5
- D) restart the postgresql database.
- # Servicepostgresql-9.4restart
(13) modify the postgresql Firewall Configuration:
[Plain] view plaincopy
- # Vim/etc/sysconfig/iptables Add the following content
[Plain] view plaincopy
- -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport5432-jACCEPT
- -AINPUT-mstate -- stateNEW-mtcp-ptcp -- dport80-jACCEPT
- # Restarting the Firewall
- # Sudoserviceiptablesrestart
(14) modify the postgres User Password
[Plain] view plaincopy
- # Sudo-passwd-upostgres
- # 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