您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

centos安装postgresql和postgis

bubuko 2022/1/25 20:09:56 其他 字数 2114 阅读 995 来源 http://www.bubuko.com/infolist-5-1.html

1、安装步骤-- 安装对应的rpm文件(其他系统的rpm包,请自行到https://yum.postgresql.org/下载)yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg ...

1、安装步骤

-- 安装对应的rpm文件(其他系统的rpm包,请自行到https://yum.postgresql.org/下载)
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

-- 查询postgresql的版本

yum search postgresql
-- 安装对应的版本(我安装的是postgresql9.6+postgis2.4)
yum -y install postgresql96.x86_64 postgresql96-server.x86_64 postgresql96-devel.x86_64
-- 安装对应的postgis插件
yum install postgis2_96.x86_64
如果出现如下图所示错误,

技术分享图片

 

请执行如下命令:rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

执行完毕后,继续执行yum install postgis2_96.x86_64

至此整个安装过程完毕!

  2、初始化运行环境

-- 初始化数据库
/usr/pgsql-9.6/bin/postgresql96-setup initdb
-- 启动psql服务器
systemctlstart postgresql-9.6
--设置开机自启动
systemctl enable postgresql-9.6
--开发防火墙
firewall-cmd--permanent --add-port=5432/tcp
firewall-cmd--reload
-- 修改pg_hba.conf和postgresql.conf
/var/lib/pgsql/data/pg_hba.conf 将配置文件中记录的method的ident修改为trust(可以实现用户名和密码访问数据库)
/var/lib/pgsql/data/postgresql.conf 修改listen_addresses = ‘localhost‘为listen_addresses= ‘*‘,允许所有远程访问
(这样可以在其它客户机上远程登陆服务器,比如在windows机器上使用pgadmin客户端)

-- 初始化数据库

su postgresql

--登录到数据库

psql(可以默认登陆到用户名为:postgres 数据库名为postgres的数据库)

--查看当前连接到的数据库

\c

--查看当前的数据库信息

\l

--查看当前数据库的表信息

\d

--导入sql脚本

第一种方法:\i  sql脚本的路径信息 

第二种:psql -U 用户 -d 数据库 -h 主机 -p 端口 -f 脚本路径

 

至此基本的安装,初始化过程就结束了,  如果你在过程中有任何疑问,欢迎交流学习!

 

centos安装postgresql和postgis

原文:https://www.cnblogs.com/ljy-20180122/p/12371929.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶