ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

CentOS 8 安装部署Postgresql 13

2021-07-13 18:58:09  阅读:360  来源: 互联网

标签:13 postgresql postgres CentOS sudo 64 Postgresql root


安装:
# sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# sudo dnf -qy module disable postgresql

# sudo dnf install -y postgresql13-server

Dependencies resolved.
================================================================================
 Package                  Arch        Version                 Repository   Size
================================================================================
Installing:
 postgresql13-server      x86_64      13.3-2PGDG.rhel8        pgdg13      5.5 M
Installing dependencies:
 libicu                   x86_64      60.3-2.el8_1            baseos      8.8 M
 postgresql13             x86_64      13.3-2PGDG.rhel8        pgdg13      1.5 M
 postgresql13-libs        x86_64      13.3-2PGDG.rhel8        pgdg13      413 k

Transaction Summary
================================================================================
Install  4 Packages

[root@centos8 ~]# sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

[root@centos8 ~]# sudo systemctl enable postgresql-13
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-13.service → /usrrvice.
[root@centos8 ~]# sudo systemctl start postgresql-13

说明:
postgresql-client	libraries and client binaries
postgresql-server	core database server
postgresql-contrib	additional supplied modules
postgresql-devel	libraries and headers for C language development


-- 切换用户 创建用户和数据库:
[root@centos8 ~]# su - postgres
[postgres@centos8 ~]$ psql
psql (13.3)
Type "help" for help.

postgres=# create user root with password 'oracle';
CREATE ROLE

postgres=# create database product owner root;
CREATE DATABASE
postgres=# grant all privileges on database product to root;
GRANT

--退出:
postgres=# \q
postgres=# quit


配置postgresql 可以远程访问:
#添加/修改:在所有IP地址上监听,从而允许远程连接到数据库服务器
# vim /var/lib/pgsql/13/data/postgresql.conf
listening_address:'*'
#listen_addresses = 'localhost'         # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
#port = 5432                            # (change requires restart)
max_connections = 100                   # (change requires restart)

#添加/修改:允许任意用户从任意机器上以密码方式访问数据库,把下行添加为第一条规则:
加入:
# vim /var/lib/pgsql/13/data/pg_hba.conf
host    all           all             0.0.0.0/0                md5

重启服务器:
# sudo systemctl restart postgresql-13

标签:13,postgresql,postgres,CentOS,sudo,64,Postgresql,root
来源: https://blog.csdn.net/vkingnew/article/details/118708140

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有