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

Centos73 postgresql9.6.2rpm installation

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Postgresql9.6.2 rpm installation

1. Install the RPM package

Rpm-ivf postgresql96-libs-9.6.2-2PGDG.rhel7.x86_64.rpm

Rpm-ivf postgresql96-9.6.2-2PGDG.rhel7.x86_64.rpm

Rpm-ivf postgresql96-server-9.6.2-2PGDG.rhel7.x86_64.rpm

Rpm-ivf postgresql96-contrib-9.6.2-2PGDG.rhel7.x86_64.rpm

Rpm-ivf postgresql96-devel-9.6.2-2PGDG.rhel7.x86_64.rpm

2. Initialize the PostgreSQL database

/ usr/pgsql-9.6/bin/postgresql96-setup initdb

3. Start the service

Systemctl start postgresql-9.6.service

4. Add the PostgreSQL service to the startup list

Systemctl enable postgresql-9.6.service

5. Modify the password of the PostgreSQL database user postgres (note that it is not the linux system account)

PostgreSQL database default will create a postgres database user as the database administrator, the default password is empty, we need to change to the specified password, here set to 'postgres'.

# su-postgres switches users, and the prompt will change to'- bash-4.2 $'after execution

$psql logs in to the database, and the prompt changes to 'postgres=#' after execution

Postgres=# alter user postgres with password 'postgres'

ALTER ROLE

Postgres=# select * from pg_shadow

6. Test database

6.1 create a test database

Postgres=# create database test

6.2. switch to david database

#\ c test

6.3. Create a test table

Test=# create table T1 (id integer, name text)

6.4. Insert test data

Test=# insert into T1 values (1memery T1')

INSERT 0 1

Test=#

6.5. Select data

Test=# select * from T1

Id | name

-- +-

1 | T1

(1 row)

Test=#

The test is complete and the RPM package is installed successfully.

7. Modify the password of the linux system user postgres

By default, the PostgreSQL database creates a linux system user, postgres, and sets the system user's password to postgres through the passwd command.

# passwd postgres

8. Modify PostgresSQL database configuration to achieve remote access

8.1 modify the postgresql.conf file

# vim / var/lib/pgsql/9.6/data/postgresql.conf

If you want PostgreSQL to listen on the entire network, remove the # before listen_addresses and change listen_addresses = 'localhost' to listen_addresses =' *'

8.2 modify client authentication profile pg_hba.conf

Add the IP address or address field that requires remote access to the database to the file.

# vim / var/lib/pgsql/9.6/data/pg_hba.conf

Add in "# IPv4 local connections"

Host all all 127.0.0.1/32 ident

Host all all 192.168.1.199/24 md5

9. Restart the service for the settings to take effect

# systemctl restart postgresql-9.6.service

10. Remote testing can be accessed through cmd using client tools or machines with postgresql

Psql-U postgres-h 192.168.1.199

Question:

1), configure to support remote connection

$vim / var/lib/pgsql/9.6/data/pg_hba.conf

# directly configure to not limit IP, that is, 0.0.0.0. Note: / must also be followed by 0 limit! #

Change 127.0.0.1 Compact 32 to 0.0.0.0 Universe 0

By the way, change the ident of the method attribute of this line to trust, otherwise the user will report the error of postgres ident authentication failure when connecting remotely with the client tool.

2) remove the version number to start the service

Cd / usr/lib/systemd/system

Ln-s postgresql-9.6.service postgresql.service

You can use it later.

Systemctl start postgresql

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

Database

Wechat

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

12
Report