当前位置:网站首页>Installing postgresql11 database under centos7
Installing postgresql11 database under centos7
2022-07-07 07:48:00 【Guardian stone】
1. obtain PG Of Repo file
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpmWe can know through the following command repo The installation directory of the file :
[[email protected] ~]# rpm -ql pgdg-redhat-repo
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
/etc/yum.repos.d/pgdg-redhat-all.repo
pgdg-redhat-all.repo File for yum Remote installation provides PostgreSQL Remote installation source for .
2. install PostgreSQL Client and server
yum install postgresql11 postgresql11-serverAll the way y Key will do .
3. initialization
/usr/pgsql-11/bin/postgresql-11-setup initdbAnd then postgresql Service join self start and start PostgreSQL
systemctl enable postgresql-11
systemctl start postgresql-114. permissions
installation is complete PostgreSQL After the client , Will be for Linux establish postgres Account , Let's set the password for this account first .
passwd postgresNew password:
Retype new password:
Input separately “ Your password ”
next , Linux from root Downgrade to postgres The user login shell terminal ( perhaps SSH), adopt pgsql Order to enter PG Console , Set up PG Super tube user postgres Password .
su postgres
psql
alter user postgres with password ' Your password ';
exit5. modify PG Related configuration files , Set external access control rules
First configuration postgresql.conf file , to open up PG Network access port .
vi /var/lib/pgsql/11/data/postgresql.confmodify listen_addresses The value of is ‘*’:
listen_addresses = '*' # what IP address(es) to listen on;Next configuration pg_hba.conf file , Fine grained control PG Service access and PG Master slave copied IP paragraph
vi /var/lib/pgsql/11/data/pg_hba.confFocus on the following configuration line. The end is “md5” Modification of configuration items :
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.83.0/16 md5
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all md5
host replication all 127.0.0.1/32 md5
host replication all 192.168.83.0/24 md5
host replication all ::1/128 identIn the above configuration PostgreSQL Access to database services IP Configuration is 192.168.83.0/16 , The mask bit is 16, Then you can visit IP Segment is 192.168.0.1~192.168.255.254.
PostgreSQL Replication of services (replication) visit IP Configuration is 192.168.83.0/24, The mask bit is 24, Then you can visit IP Segment is 192.168.83.1~192.168.83.254.
notes : If you want to let go completely PostgreSQL Access control , Only need to 192.168.83.0/16 Change it to 0.0.0.0/0.
Finally, we need to return root user , restart PG service , Make the configuration work .
systemctl restart postgresql-116. Other configuration
(1) Linux Downgrade login again postgres user , And then use pgsql Order to enter PG Console , Let's see. PostgreSQL Is it a Chinese environment .
select * from pg_database;We focus on datcollate,datctype Two , See if it is zh_CN.UTF-8
postgres=# select * from pg_database;
datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | datminmxid | dattablespace |
datacl
-----------+--------+----------+-------------+-------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+--------------
-----------------------
postgres | 10 | 6 | zh_CN.UTF-8 | zh_CN.UTF-8 | f | t | -1 | 13880 | 561 | 1 | 1663 |
template1 | 10 | 6 | zh_CN.UTF-8 | zh_CN.UTF-8 | t | t | -1 | 13880 | 561 | 1 | 1663 | {=c/postgres,
postgres=CTc/postgres}
template0 | 10 | 6 | zh_CN.UTF-8 | zh_CN.UTF-8 | t | f | -1 | 13880 | 561 | 1 | 1663 | {=c/postgres,
postgres=CTc/postgres}
(3 rows)If not , perform SQL modify :
update pg_database set datcollate='zh_CN.UTF-8',datctype='zh_CN.UTF-8';(2) Give Way postgres Users can reload pg_hba.conf The configuration file :
Return root user , Execute the following commands continuously :
echo 'export PGDATA=/var/lib/pgsql/11/data' >> /etc/profile
source /etc/profilePGDATA The environment variables have been set globally .
We are demoted to postgres user , If to modify pg_hba.conf The configuration file , Direct command execution :
/usr/pgsql-11/bin/pg_ctl reloadYou can reload pg_hba.conf The configuration file , Without having to restart postgresql-11 service .
7.PostgreSQL A brief description of the command
(1). Create database , Be sure to specify roles (PG Mainly controlled by roles ).
for example , We first pass pgsql, Used postgres Super user login :
create role health login password ' Your password ';
create database health_db with owner= health;We created roles “health”, Then create the database “health_db” When , You need to specify the owner of this database as “health”.
Corresponding delete database and role commands :
drop database health_db;
drop role health;When it comes to comprehensive operation “health_db” When it comes to databases , Please exit PG Console , Enter into Linux Of postgres User login status , Reuse “health” Character landing PG Console :
psql -U health -d health_dbWe can use the following command :
\l perhaps \l databaseName view the database
\d perhaps \d tableName Look at the data sheet
\du To view the user
\dnS View mode
\c databaseName Switch database 边栏推荐
- 外包幹了三年,廢了...
- 在线直播系统源码,使用ValueAnimator实现view放大缩小动画效果
- MobaXterm
- 2022-07-06: will the following go language codes be panic? A: Meeting; B: No. package main import “C“ func main() { var ch chan struct
- [2022 ACTF]web题目复现
- resource 创建包方式
- 今日现货白银操作建议
- JS plot flot application - simple curve
- pytest+allure+jenkins环境--填坑完毕
- [Stanford Jiwang cs144 project] lab4: tcpconnection
猜你喜欢

After 95, Alibaba P7 published the payroll: it's really fragrant to make up this

resource 创建包方式

【斯坦福计网CS144项目】Lab4: TCPConnection

知识点滴 - 关于苹果认证MFI

My ideal software tester development status

Detailed explanation of uboot image generation process of Hisilicon chip (hi3516dv300)

Iterable、Collection、List 的常见方法签名以及含义

buuctf misc USB
![[UTCTF2020]file header](/img/e3/818e2d531a06ab90de189055f634ad.png)
[UTCTF2020]file header
![[webrtc] M98 screen and window acquisition](/img/b1/1ca13b6d3fdbf18ff5205ed5584eef.png)
[webrtc] M98 screen and window acquisition
随机推荐
JS plot flot application - simple curve
ASEMI整流桥RS210参数,RS210规格,RS210封装
【性能压测】如何做好性能压测?
Common method signatures and meanings of Iterable, collection and list
[experience sharing] how to expand the cloud service icon for Visio
[SUCTF 2019]Game
What are the positions of communication equipment manufacturers?
[guess-ctf2019] fake compressed packets
[unity] several ideas about circular motion of objects
[P2P] local packet capturing
Live online system source code, using valueanimator to achieve view zoom in and out animation effect
1140_ SiCp learning notes_ Use Newton's method to solve the square root
即刻报名|飞桨黑客马拉松第三期等你挑战
[UTCTF2020]file header
Pytorch parameter initialization
[2022 ciscn] replay of preliminary web topics
Few-Shot Learning && Meta Learning:小样本学习原理和Siamese网络结构(一)
直播平台源码,可折叠式菜单栏
为什么要了解现货黄金走势?
[Stanford Jiwang cs144 project] lab4: tcpconnection