centos7 安装最新版postgresql13

    在mysql被收购之后,大家发现了另一款开源的数据库,postgresql,比如PostgreSQL有一个MySQL无法比拟的优势,那就是PostGIS,PostGIS可以完美支持空间数据存储和空间分析;从PostgreSQL9.3起就内置了JSON数据类型,而9.4又开始支持JSONB,这标志着PostgreSQL实际上已经是一个关系型数据库和NoSQL数据库的结合体了、虽然postgresql是一个关系型数据库,但是近几次更新PostgreSQL的NoSQL性能有益到甚至超过了MongoDB。
 

 一:PostgreSQ官网下载地址

https://www.postgresql.org/download/

选择你需要下载的环境

选择你的系统环境

 

然后安装 postgresql-13

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
sudo yum install -y postgresql13-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13

 postgresql在安装时默认添加用户postgres

su - postgres
psql

 

 我们来设置密码后再推出


postgres=# ALTER USER postgres WITH PASSWORD '123456';
ALTER ROLE
postgres=# \q

配置远程连接,需要设置pg_hba.conf

vim /var/lib/pgsql/13/data/pg_hba.conf

保存退出

配置远程连接的地址和端口号

vim /var/lib/pgsql/13/data/postgresql.conf 

重启服务:

systemctl restart postgresql-13

 

通过Navicat连接后,执行创建表,删除表,插入数据,查找数据

SELECT * FROM s_mileage_sta;

-- ----------------------------
-- Table structure for s_mileage_sta
-- ----------------------------
DROP TABLE s_mileage_sta;
CREATE TABLE s_mileage_sta (
  id VARCHAR(32) primary key, 
  mileage int 
) ;

-- ----------------------------
-- Records of s_mileage_sta
-- ----------------------------
INSERT INTO s_mileage_sta VALUES ('2021-05-11 00:00:00', 206638);
INSERT INTO s_mileage_sta VALUES ('2021-05-13 00:00:00', 0);

查询速度很快 

 

猜你喜欢

转载自blog.csdn.net/weixin_42575806/article/details/116987440