postgresql卸载-安装-创建数据库-连接-删除数据库-基本命令

本文详细介绍了如何卸载和安装PostgreSQL,创建数据库,连接数据库的步骤,并提供了查看现有数据库、切换数据库、查看表、删除数据库等基本命令操作。在连接数据库时,重点强调了配置pg_hba.conf和postgresql.conf文件的重要性。
摘要由CSDN通过智能技术生成

卸载安装

如果postgresql不是你想要的版本,先卸载再安装

[root@localhost ~]# yum remove postgresql*
yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7.8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql95-server.x86_64
yum install -y postgresql95-contrib.x86_64

启动数据库

[root@localhost bin]# /usr/pgsql-9.5/bin/postgresql95-setup initdb
Initializing database ... OK
[root@localhost bin]# systemctl enable postgresql-9.5
[root@localhost bin]# systemctl start postgresql-9.5

创建数据库

[root@localhost bin]# su - postgres
postgres=# create user sonar with password 'sonar';
CREATE ROLE
postgres=# create database sonardb owner sonar;
CREATE DATABASE
postgres=# grant all on database sonardb to sonar;
GRANT
[root@localhost bin]# su - sonar
[sonar@localhost ~]$ psql -U sonar -W sonardb
Pa
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值