当前位置:网站首页>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/profile3、 initialization PG, And start the PG
/usr/pgsql-13/bin/postgresql-13-setup initdbsystemctl enable postgresql-13systemctl start postgresql-13systemctl status postgresql-134、 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-port6、 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-137、 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/postgresamong -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_profileInstallation configuration completed , If you don't understand , You can chat with Mr. Mai privately .
边栏推荐
- 三句话简要介绍子网掩码
- The tutorial of computer reinstallation win10 system is simple and easy to understand. It can be reinstalled directly without U disk
- App general function test cases
- Wind chime card issuing network source code latest version - commercially available
- Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
- Summary of three methods for MySQL to view table structure
- PostgreSQL使用Pgpool-II实现读写分离+负载均衡
- 基于SSM框架实现的房屋租赁管理系统
- The important data in the computer was accidentally deleted by mistake, which can be quickly retrieved by this method
- DAY FIVE
猜你喜欢

The programmer refused the offer because of low salary, HR became angry and netizens exploded

Master binary tree in one article

What should I do if the USB flash disk data is formatted and how can I recover the formatted USB flash disk data?

人均瑞数系列,瑞数 4 代 JS 逆向分析

Gradle knowledge generalization

快手的新生意,还得靠辛巴吆喝?

How rider uses nuget package offline

若依请求url中带有jsessionid的解决办法

1000 words selected - interface test basis

DAY THREE
随机推荐
本地部署 zeppelin 0.10.1
How about the order management of okcc call center
pytest多进程/多线程执行测试用例
谁说新消费品牌大溃败?背后有人赢麻了
快讯 l Huobi Ventures与Genesis公链深入接洽中
Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
Common modification commands of Oracle for tables
How does crmeb mall system help marketing?
量子时代计算机怎么保证数据安全?美国公布四项备选加密算法
[system analyst's road] Chapter 7 double disk system design (service-oriented development method)
web渗透测试是什么_渗透实战
MATLIB reads data from excel table and draws function image
[212] what are three methods for PHP to send post requests
Master binary tree in one article
Cas d'essai fonctionnel universel de l'application
亚朵三顾 IPO
How to answer the dualistic opposition of Zhihu
《LaTex》LaTex数学公式简介「建议收藏」
STM32 enters and wakes up the stop mode through the serial port