如何访问云数据库PostgreSQL实例?

知识问答作者:U大使日期:2021-01-24点击:168

如何访问云数据库PostgreSQL实例

1、主机安装psql
在官网yum源复制对应版本的下载链接,更新yum源(官网:https://yum.postgresql.org/repopackages.php )

yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
查看postgresql源
yum list |grep postgresql

安装对应版本的上面两个安装包
yum install -y postgresql10-contrib postgresql10-server
初始化数据库
/usr/pgsql-10/bin/postgresql-10-setup initdb

启动数据库
systemctl start postgresql-10
systemctl enable postgresql-10
2、访问postgresql实例
su postgres
psql -U$User -h$IP -p$port -d$dbname
$User指定PostgreSQL实例的管理员用户。
$IP指定PostgreSQL实例的内网IP地址。
$Port指定PostgreSQL实例的端口(默认5432)。
$dbname指定数据库 (例:postgres)

下一篇       上一篇