当前位置:网站首页>PostgreSQL DBA quick start - source compilation and installation
PostgreSQL DBA quick start - source compilation and installation
2022-06-24 09:53:00 【post_ yuan】
This article introduces through PostgreSQL The official source installation package is compiled and installed to get started quickly PostgreSQL database .
Prerequisite
- install gmake, adopt gmake -v see
- install gcc, adopt which gcc see
- install tar, adopt tar --help see
- install GNU readline library, Support up and down buttons 、 Fallback key, etc , adopt rpm -qa | grep readline see
- install Zlib compression library, For compression function
Create user
- id postgres - Check to see if there is postgres user
- groupadd postgres - add to postgres Group
- useradd -g postgres postgres - add to postgres user
- passwd postgres - modify postgres password
- mkdir -p /data/postgres/13.2/ - Create database directory
- chown -R postgres:postgres /data/ - Modify database directory permissions
Install and start the database
- su – postgres - Switch postgres user
- wget xxx.tar.gz - Download source package
- tar -xzvf xxx.tar.gz - decompression
- cd postgresql-13.2 - Toggle directory
- ./configure –preifx=/data/postgres/13.2/ - perform configure
- gmake world - perform gmake
- gmake install-world - perform gmake install
- /data/postgres/13.2/bin/initdb -d /data/postgres/13.2/data - Initialize database
- /data/postgres/13.2/pg_ctl -D /data/postgres/13.2/data -l logfile start - Start database
Modify environment variables
The purpose is to eliminate the need to specify an executable ( Such as psql、pg_ctl etc. ) The absolute path of
- modify postgres User ~/.bash_profile, It can also be modified directly ~/.bashrc
PATH=xxx:/data/postgres/13.2/bin
PGDATA=/data/postgres/13.2/data
export PATH
export PGDATA - source ~/.bashrc
- perform psql Verify that the environment variable modification takes effect
Modify database configuration
stay /data/postgres/13.2/data/pg_hba.conf in , Add the following line :
host all all 0.0.0.0/0 md5
The above means for all uses IPV4 The client machine of , Allow any IP, Any user can initiate access to the database , But the database user password must be provided , The authentication method is through MD5 Encryption Authentication .stay /data/postgres/13.2/data/data/postgresql.conf in , modify
#listen_addresses=’localhost’ by listen_addresses=’*’
Need to restart
pg_ctl restart -m fast
Indicates that any client is allowed to access
How to start and stop a database
- ps -ef | grep postges - Check whether the database is running
- pg_ctl stop -m fast - Stop database
- pg_ctl start -D /data/postgres/13/2/data -l ~/startup.log - Start database
- pg_ctl status - Check database status
be familiar with psql Command line tools
which psql
psql --help
psql -h localhost -p 5432 -d postgres -U postgres
\c - Check which user is connected to which database
\d – See the table
\d <tablename> - View table structure
\i ext.sql - Execute a file , amount to Oracle Medium @
\h - Check all commands
\h create table - see create table Help document for
select version(); - View version
\l - View all database information
\l+ - View database information and size information
select pg_postmaster_start_time();
\du - View user information
\dt+ - Check the table size
\di+ - View index information
\dv - View view
\df - View functions
边栏推荐
- Thinkphp5 multi language switching project practice
- Oracle数据库监听文件配置
- indexedDB本地存储,首页优化
- Learn Tai Chi Maker - esp8226 (12) esp8266 multitasking
- el-table点击添加行样式
- PRCT-1400 : 未能执行 getcrshome解决方法
- 顶刊TPAMI 2022!基于不同数据模态的行为识别:最新综述
- 5分钟,客服聊天处理技巧,炉火纯青
- Implementation of simple floating frame in WindowManager
- 【Eureka注册中心】
猜你喜欢

Amazing tips for using live chat to drive business sales

Oracle 12c升级至19c后ORA-28000错误

使用Live Chat促進業務銷售的驚人技巧

Basic operations on binary tree

英伟达这篇CVPR 2022 Oral火了!2D图像秒变逼真3D物体!虚拟爵士乐队来了!

小程序学习之获取用户信息(getUserProfile and getUserInfo)

Record the range of data that MySQL update will lock

PTA monkey chooses King (Joseph Ring problem)

PTA猴子选大王(约瑟夫环问题)

CICFlowMeter源码分析以及为满足需求而进行的修改
随机推荐
ByteDance Interviewer: talk about the principle of audio and video synchronization. Can audio and video be absolutely synchronized?
小程序学习之获取用户信息(getUserProfile and getUserInfo)
June 13-19, 2022 AI industry weekly (issue 102): career development
实战剖析:app扫码登陆实现原理(app+网页端详细逻辑)附源码
port 22: Connection refused
英伟达这篇CVPR 2022 Oral火了!2D图像秒变逼真3D物体!虚拟爵士乐队来了!
达梦数据库如何定位锁等待问题解决方法
Dragging El table sortablejs
Symbol. Iterator iterator
深度学习论文阅读目标检测篇(七)中英对照版:YOLOv4《Optimal Speed and Accuracy of Object Detection》
Endgame P.O.O
Oracle database listening file configuration
针对《VPP实现策略路由》的修正
[Eureka source code analysis]
GIS实战应用案例100篇(十四)-ArcGIS属性连接和使用Excel的问题
Ora-28000 error after upgrading Oracle 12C to 19C
Oracle的tnsnames.ora文件配置
el-table表格的拖拽 sortablejs
Can the long-term financial products you buy be shortened?
PTA monkey chooses King (Joseph Ring problem)