当前位置:网站首页>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 .
边栏推荐
- 士大夫哈哈哈
- 三句话简要介绍子网掩码
- How to find out if the U disk file of the computer reinstallation system is hidden
- Oracle对表进行的常用修改命令
- Can online reload system software be used safely? Test use experience to share with you
- 【向量检索研究系列】产品介绍
- 公链与私链在数据隐私和吞吐量上的竞争
- matplotlib画柱状图并添加数值到图中
- DAY TWO
- Building lease management system based on SSM framework
猜你喜欢
Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
Automatic test tool katalon (WEB) test operation instructions
Gradle knowledge generalization
量子时代计算机怎么保证数据安全?美国公布四项备选加密算法
吴恩达2022机器学习课程评测来了!
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
服务器SMP、NUMA、MPP体系学习笔记。
随机推荐
Penetration test --- database security: detailed explanation of SQL injection into database principle
为什么完全背包要用顺序遍历?简要解释一下
If the request URL contains jsessionid, the solution
量子时代计算机怎么保证数据安全?美国公布四项备选加密算法
[unmanned aerial vehicle] multi unmanned cooperative task allocation program platform, including Matlab code
使用源码编译来安装PostgreSQL13.3数据库
Interface joint debugging test script optimization v4.0
DAY FIVE
Do you still have to rely on Simba to shout for a new business that is Kwai?
matplotlib画柱状图并添加数值到图中
【212】php发送post请求有哪三种方法
谁说新消费品牌大溃败?背后有人赢麻了
The programmer refused the offer because of low salary, HR became angry and netizens exploded
Basic chart interpretation of "Oriental selection" hot out of circle data
leetcode:236. 二叉树的最近公共祖先
[communication] optimal power allocation in the uplink of two-layer wireless femtocell network with matlab code
电脑重装系统u盘文件被隐藏要怎么找出来
AI金榜题名时,MLPerf榜单的份量究竟有多重?
Summary of three methods for MySQL to view table structure
app通用功能测试用例