PostgreSQL: The World's Most Advanced Open Source Relational Database
为了学一学号称世界上最早进的开源关系型数据库,就要先安装,接下来就在CentOS 7上安装PostgreSQL 11。sql
阿里云 CentOS 7.3.1611PostgreSQL 11shell
PostgreSQL是以加州大学伯克利分校计算机系开发的 POSTGRES,如今已经改名为PostgreSQL,版本 4.2为基础的对象关系型数据库管理系统(ORDBMS)。PostgreSQL支持大部分 SQL标准而且提供了许多其余现代特性:复杂查询、外键、触发器、视图、事务完整性、MVCC。一样,PostgreSQL 能够用许多方法扩展,好比, 经过增长新的数据类型、函数、操做符、汇集函数、索引。无偿使用、修改、和分发 PostgreSQL,无论是私用、商用、仍是学术研究使用。 PostgreSQL从9.3版本开始内置了JSON数据类型,而9.4开始支持JSONB,标志着<span style="color: yellow;">PostgreSQL实际上已是一个关系型数据库和NoSQL数据库的结合体</span>。虽然PostgreSQL还定位在关系型数据库,可是<span style="color: yellow;">近几回更新PostgreSQL的NoSQL性能飙升甚至超过MongoDB</span>。
这里以rpm的方式安装PostgreSQL 11数据库
# 下载rpm包 yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-redhat11-11-2.noarch.rpm -y # 安装 yum -y install postgresql11 postgresql11-server postgresql11-libs # 初始化数据库 /usr/pgsql-11/bin/postgresql-11-setup initdb # 设置开机自启动PostgreSQL和启动服务 systemctl enable postgresql-11 systemctl start postgresql-11 systemctl status postgresql-11 ## 看到控制台输出的Active后有Running的字样说明启动完成
# 登陆数据库,这里切换帐号postgres su - postgres psql # Navicat链接PostgreSQL # 这里要修改配置文件postgresql.conf find / -name postgresql.conf vi /var/lib/pgsql/11/data/postgresql.conf # 找到listen_address那里,解开注释并修改引号内localhost的值为* listen_address="*" # 保存并退出,重启postgresql服务 systemctl restart postgresql-11 # 修改远程链接pg_hba.conf find / -name pg_hba.conf vi /var/lib/pgsql/11/data/pg_hba.conf # 在文件末尾加上,若是不加上远程链接PostgreSQL会出现no pg_hba.conf...的错误 host all all 0.0.0.0/0 trust # 阿里云安全组规则配置 -> 快速添加安全组规则 -> 选中PostgreSQL并添加 # 在navicat链接,若是不修改localhost为*,navicat链接会提示错误“Connection Refuse” # 我在这里修改了postgres用户的密码,步骤以下: ## 切换用户后进入psql su - postgres psql ## 修改密码 alter user postgres password '密码'
链接成功!安全
至此,PostgreSQL搭建完成,Windows平台下的PostgreSQL搭建比较简单。接下来,学PostgreSQL!函数