当前位置:网站首页>Use Yum or up2date to install the postgresql13.3 database
Use Yum or up2date to install the postgresql13.3 database
2022-07-06 23:53:00 【Hua Weiyun】
1、 Installation Overview
PG There are many ways to install , and MySQL similar , Give users a lot of choice . Such as :RPM Package installation ( On-line 、 offline )、 Source code compilation and installation 、 System comes with 、 Binary system 、NDB Installation, etc .
https://yum.postgresql.org/rpmchart.php
https://yum.postgresql.org/11/redhat/rhel-6-x86_64/repoview/postgresqldbserver11.group.html
https://www.postgresql.org/ftp/source/
open PostgreSQL Official website https://www.postgresql.org/, Click... On the menu bar Download , As you can see, there are many installation packages for the platform , Include Linux、Windows、Mac OS etc. .
Each installation package :https://www.postgresql.org/ftp/source/
Linux We can see support Ubuntu and Red Hat And so on , Click on the specific platform link , You can see the installation method :
Click on the image above file browser, We can also download PostgreSQL The latest source code .
Download address :
https://www.postgresql.org/download
https://yum.postgresql.org/repopackages.php
file :https://www.postgresql.org/download/linux/redhat/
rpm download :https://yum.postgresql.org/rpmchart/
2、yum Online installation
-- Some dependency packages yum install -y cmake make gcc zlib gcc-c++ perl readline readline-devel zlib zlib-devel \perl python36 tcl openssl ncurses-devel openldap pam-- Delete existing PGyum remove -y postgresql* && rm -rf /var/lib/pgsql && rm -rf /usr/pgsql* && userdel -r postgres && groupdel postgresyum install -y sysbench-- install yum Source yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpmyum repolist all | grep pgdgyum repolist enabled | grep pgdg-- install pgyum install -y postgresql13 postgresql13-server postgresql13-contrib postgresql13-libs# yum install -y postgresql9.6 postgresql9.6-server# yum install postgresql10-server postgresql10-contrib postgresql10 postgresql10.x86_64-- verification [root@lhrpg /]# rpm -aq| grep postgrespostgresql13-server-13.3-1PGDG.rhel7.x86_64postgresql13-13.3-1PGDG.rhel7.x86_64postgresql13-libs-13.3-1PGDG.rhel7.x86_64postgresql13-contrib-13.3-1PGDG.rhel7.x86_64-- environment variable echo "export PATH=/usr/pgsql-13/bin:$PATH" >> /etc/profile
3、 initialization PG, And start the PG
/usr/pgsql-13/bin/postgresql-13-setup initdbsystemctl enable postgresql-13systemctl start postgresql-13systemctl status postgresql-13
4、 Change Password
-- Local landing su - postgrespsql-- Installing a plug-in create extension pageinspect;create extension pg_stat_statements;select * from pg_extension ;select * from pg_available_extensions order by name;-- modify postgres password alter user postgres with encrypted password 'lhr'; or \passwordselect * from pg_tables;select version();
5、 Open the firewall
-- Open the firewall firewall-cmd --add-port=5432/tcp --permanentfirewall-cmd --reloadfirewall-cmd --list-port
6、 Configuration allowed PG Remote login
-- Configuration allowed PG Remote login , Note that version :cat >> /var/lib/pgsql/13/data/postgresql.conf <<"EOF"listen_addresses = '*'port=5432unix_socket_directories='/var/lib/pgsql/13/data'logging_collector = onlog_directory = 'pg_log'log_filename = 'postgresql-%a.log'log_truncate_on_rotation = onEOFcat << EOF > /var/lib/pgsql/13/data/pg_hba.conf# TYPE DATABASE USER ADDRESS METHODlocal all all trusthost all all ::1/128 trusthost all all 127.0.0.1/32 trusthost all all 0.0.0.0/0 md5host replication all 0.0.0.0/0 md5EOFsystemctl restart postgresql-13
7、 Login test
-- Remote login psql -U postgres -h 192.168.66.35 -d postgres -p54327-- from Postgresql 9.2 Start , You can also use URI Format for remote connection :psql postgresql://myuser:[email protected]:5432/mydbpsql postgresql://postgres:[email protected]:54327/postgres
among -h Parameter specifies the server address , The default is 127.0.0.1, It is not specified by default ,-d Specify the database selected after connection , The default is postgres,-U Designated user , The default is the current user ,-p Specify port number , The default is "5432", More parameter options are available : ./bin/psql --help see .
C:\Users\lhrxxt>psql -U postgres -h 192.168.66.35 -d postgres -p54327Password for user postgres:psql (13.3)Type "help" for help.postgres=# select version(); version------------------------------------------------------------------------------------------------------------------ PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit(1 row)postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges-----------+----------+----------+-------------------+-------------------+----------------------- postgres | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | template0 | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | =c/postgres + | | | | | postgres=CTc/postgres(3 rows)postgres=# CREATE DATABASE lhrdb WITH OWNER=postgres ENCODING='UTF-8';CREATE DATABASEpostgres=# \c lhrdbYou are now connected to database "lhrdb" as user "postgres".lhrdb=#lhrdb=# create table student (lhrdb(# id integer not null,lhrdb(# name character(32),lhrdb(# number char(5),lhrdb(# constraint student_pkey primary key (id)lhrdb(# );CREATE TABLElhrdb=#lhrdb=# \d student Table "public.student" Column | Type | Collation | Nullable | Default--------+---------------+-----------+----------+--------- id | integer | | not null | name | character(32) | | | number | character(5) | | |Indexes: "student_pkey" PRIMARY KEY, btree (id)lhrdb=#lhrdb=# INSERT INTO student (id, name, number) VALUES (1, ' Zhang San ', '1023');INSERT 0 1lhrdb=# SELECT * FROM student WHERE id=1; id | name | number----+------------------------------------+-------- 1 | Zhang San | 1023(1 row)
8、 Configure environment variables
mkdir -p /home/postgreschown postgres.postgres /home/postgres -Rsed -i 's|/var/lib/pgsql|/home/postgres|' /etc/passwdecho "lhr" |passwd --stdin postgrescat > /home/postgres/.bash_profile <<"EOF"export PGPORT=5432export PGHOME=/usr/pgsql-13export PGDATA=/var/lib/pgsql/13/dataexport PATH=$PGHOME/bin:$PATHexport MANPATH=$PGHOME/share/man:$MANPATHexport LANG=en_US.UTF-8export DATE='date +"%Y%m%d%H%M"'export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATHexport PGHOST=$PGDATAexport PGUSER=postgresexport PGPASSWORD=lhrexport PGDATABASE=postgresexport PS1="[\[email protected]\h \W]\$ "alias psql='rlwrap psql' EOFchown postgres.postgres /home/postgres/.bash_profile
Installation configuration completed , If you don't understand , You can chat with Mr. Mai privately .
边栏推荐
- 1000 words selected - interface test basis
- Design of short chain
- Master binary tree in one article
- 基于SSM框架实现的房屋租赁管理系统
- 本地部署 zeppelin 0.10.1
- 【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
- [212] what are three methods for PHP to send post requests
- Wind chime card issuing network source code latest version - commercially available
- Penetration test --- database security: detailed explanation of SQL injection into database principle
- 服务器SMP、NUMA、MPP体系学习笔记。
猜你喜欢
MVC and MVVM
公链与私链在数据隐私和吞吐量上的竞争
pytest多进程/多线程执行测试用例
设计一个抢红包系统
Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
[automated testing framework] what you need to know about unittest
Today, I met a senior test developer from Tencent and saw the ceiling of the foundation
Gradle知識概括
AI金榜题名时,MLPerf榜单的份量究竟有多重?
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
随机推荐
(LeetCode)两数之和
How to implement Lua entry of API gateway
DevOps可以帮助减少技术债务的十种方式
Building lease management system based on SSM framework
Entropy information entropy cross entropy
Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
《LaTex》LaTex数学公式简介「建议收藏」
MATLIB reads data from excel table and draws function image
Wasserstein Slim GAIN with Gradient Penalty(WSGAIN-GP)介绍及代码实现——基于生成对抗网络的缺失数据填补
每年 2000 亿投资进入芯片领域,「中国芯」创投正蓬勃
How much does the mlperf list weigh when AI is named?
Experiment 6: installing eve-ng
Restoration analysis of protobuf protocol of bullet screen in station B
STM32 enters and wakes up the stop mode through the serial port
Wu Enda 2022 machine learning course evaluation is coming!
在docker中快速使用各个版本的PostgreSQL数据库
Today, I met a senior test developer from Tencent and saw the ceiling of the foundation
The best sister won the big factory offer of 8 test posts at one go, which made me very proud
为什么完全背包要用顺序遍历?简要解释一下
内网穿透zerotier 外网(手机、电脑等)访问内网设备(树莓派、NAS、电脑等)