Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Steps to install and configure postgresql for linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you the steps of linux installation and configuration of postgresql, the code is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Install postgresql-related packages through yum

Sudo yum install-y postgresql postgresql-server postgresql96-devel postgresql-contrib postgresql-docs

Initialize the database

Sudo service postgresql initdb / / determine the version of postgresql based on the installed version eg: sudo service postgresql96 initdb

Start the database

Sudo service postgresql start

Create users and data

/ / first log in to postgres user sudo su postpres psql// and enter psql after entering the previous command, then you can enter the sql statement create user testuser with password 'testpwd';// to create a database create database testdb owner testuser; / / grant users the right to operate the database grant all privileges on database testdb to testuser \ Q exit / / modify the configuration file, and the setting data can access the sudo cd / var/lib/pgsql/data / / edit file sudo vim postgresql.conf remotely.

Modify a file

Listen_addresses = 'localhost' changed to listen_addresses =' *'

Modify the file pg_hba.conf

Add a line at the bottom of the file

Host all all 0.0.0.0/0 md5

/ / restart the service

Note: check to see if the permission of the data file is 700. if not, change it to 700 sudo chmod 700 / var/bin/data/

Sudo service restart postgresql

Test connection

Psql-h *. *-d testdb-U testuser

Errors that may be encountered

Peer authentication failed for user "postgres"

Solution method

Sudo vim / var/lib/pgsql/data/pg_hba.conf

Change host all all peer to

Host all all trust

If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report