centos7安装postgres13.1数据库
source link: https://blog.51cto.com/u_13753753/5755170
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
centos7安装postgres13.1数据库
精选 原创雍州无名 2022-10-14 09:29:49 博主文章分类:postgresql ©著作权
文章标签 postgresql sql 创建用户 文章分类 其它 系统/运维 阅读数216
1.安装postgres的yum仓库
下载所需要的数据库版本: https://yum.postgresql.org/repopackages/
安装yum仓库
2.安装postgresql
(1).先查看postgresql源
(2).安装postgresql
(3).初始化postgresql
安装目录:/usr/pgsql-13
(4).启动postgresql
systemctl enable postgresql-13.service
查看是否启动成功
3.登录postgresql并设置密码
postgresql在安装时默认添加用户postgres
然后输入以下命令进入postgres
备注其他:列出所有库\l 列出所有用户\du 列出库下所有表\d
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres=#
postgres=#
postgres=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
postgres=#
4.默认情况下postgresql是不用密码不支持远程登录的。我们需要修改配置文件
vim /var/lib/pgsql/13/data/pg_hba.conf
host all all 0.0.0.0/0 trust
host replication all 0.0.0.0/0 trust
再修改配置文件postgresql.conf
vim /var/lib/pgsql/13/data/postgresql.conf
重启postgresql
5.创建数据库及创建用户
因为postgres属于superuser,我们需要创建部分低权限用户
(1).创建数据库
(2).创建用户
(3).将testdb所有权限赋给用户testuser
注:如果要删除此账户可以使用 drop role testuser;
6.使用连接工具DBeaver连接PostgreSQL
数据库名:postgres
密码:123456
端口:5432
- 赞
- 收藏
- 评论
- 分享
- 举报
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK