CentOS6 在线安装PostgreSQL10

本文主要通过实际案例介绍如何在CentOS6环境中在线安装PostgreSQL10,安装环境需具备能够使用yum在线安装功能。具体安装步骤如下,

1 下载对应版本的PGDG文件 
https://yum.postgresql.org/repopackages.php页面找到对应的版本,这里使用https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm

2 安装上述PGDG文件

yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm
  • 1

3 yum list列出可用的postgresql资源

yum list postgresql*
  • 1

4 安装postgresql-server,其他工具可按需安装

yum install -y postgresql10-server.x86_64
  • 1

5 数据库初始化

service postgresql-10 initdb
  • 1

6 启动数据库服务

service postgresql-10 start chkconfig postgresql-10 on
  • 1
  • 2

7 连接psql客户端

[root@cent-1 ~]# su - postgres
-bash-4.1$ psql
psql (10.1)
Type "help" for help.

postgres=# \l
 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)

至此,PostgreSQL 10的安装已经完成,后面可以尝试不同的命令了,下面列出几个常用的命令,仅供参考:

//创建数据库 -bash-4.1$ createdb ly //删除数据库 -bash-4.1$ dropdb ly  //创建用户 -bash-4.1$ createuser ly //删除用户 -bash-4.1$ dropuser ly



转: https://blog.csdn.net/Post_Yuan/article/details/78920190