CentOS 7 Install, configure, and use PostgreSQL 9.5

Source: Internet
Author: User
Tags postgresql



Learn to install using PostgreSQL under CentOS



"Installation Process"



1. Add rpm
Yum Install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
2. Installing PostgreSQL 9.5



Yum Install Postgresql95-server Postgresql95-contrib



3. Initializing the database
/usr/pgsql-9.5/bin/postgresql95-setup Initdb



4. Set up boot from boot
Systemctl Enable Postgresql-9.5.service



5. Start the service
Systemctl Start Postgresql-9.5.service



Since then, the PostgreSQL 9.5 installation has been completed and the above has been used by the root user installation.



"Simple Configuration"



When the PostgreSQL installation is complete, a ' postgres ' user will be established to perform PostgreSQL, and a ' postgres ' user will be created in the database, and the default password is automatically generated and needs to be changed in the system.



6. Modify User Password
Su-postgres switch user, after execution the prompt will change to '-bash-4.2$ '
Psql-u postgres Login database, execute after prompt to ' postgres=# '
ALTER user postgres with PASSWORD ' 123456 ' Set postgres password
\q exiting the database


7. Turn on remote access
Vi/var/lib/pgsql/9.5/data/postgresql.conf
Modify #listen_addresses = ' localhost ' for listen_addresses= ' * ' Before the comments are removed Oh! 】
Of course, the ' * ' can also be changed to any server IP you want to open
8. Trusting Remote connections
Vi/var/lib/pgsql/9.5/data/pg_hba.conf
Modify the following to trust the specified server connection
# IPV4 Local connections:
Host All 127.0.0.1/32 Trust
Host All my_remote_client_ip_address/32 Trust  my_remote_client_ip_addressis the IP address of the client. 9. Open the Firewall "development environment or intranet can directly turn off the firewall"
The PostgreSQL service is built into the CentOS firewall and the configuration file location is/usr/lib/firewalld/services/postgresql.xml, so we simply open the PostgreSQL service as a service.
Firewall-cmd--add-service=postgresql--permanent Open PostgreSQL Service
Firewall-cmd--reload Heavy-duty firewall-------------------------------------shut down the firewall [[email protected] ~]# Systemctl stop Firewalld . service [[email protected] ~]# systemctl disable Firewalld.service 10. Restarting the PostgreSQL data service
Systemctl Restart Postgresql-9.5.service

Wen/lasko (author of Jane's book)
Original link: http://www.jianshu.com/p/7e95fd0bc91a


CentOS 7 Install, configure, and use PostgreSQL 9.5


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.