CentOS 7 安装、配置、使用 PostgreSQL 10 安装及基础配置
官网安装方法:https://www.postgresql.org/download/linux/redhat/
卸载的话使用 yum remove 相应的安装
Install the repository RPM:
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm
install the server packages:
yum install postgresql10-server
此时在/usr/下多了pgsql-10目录
关于安装的几个软件的介绍:
postgresql-client libraries and client binaries
postgresql-server core database server
postgresql-contrib additional supplied modules
postgresql-devel libraries and headers for C language development
pgadmin3 - pgAdmin III graphical administration utility
关于server和client的介绍参见:
https://www.postgresql.org/docs/10/static/tutorial-start.html
安装后:
设置环境变量:
略
初始化数据库:
/usr/pgsql-10/bin/postgresql-10-setup initdb
可选设置自动启动:
systemctl enable postgresql-10
systemctl start postgresql-10
启动服务:
service postgresql-10 initdb
chkconfig postgresql-10 on
直接执行createdb后会有很多问题,具体看https://www.postgresql.org/docs/10/static/tutorial-start.html
PostgreSQL 安装完成后,会建立一下‘postgres’用户,用于执行PostgreSQL,数据库中也会建立一个’postgres’用户,默认密码为自动生成,需要在系统中改一下。
修改postgres用户密码:
先切换到root
然后passwd postgress
接着输入两遍新密码
修改postgres数据库管理员密码:
su - postgres 切换用户,执行后提示符会变为 ‘-bash-4.2$’,切换为UNIX风格的bash
psql -U postgres 登录数据库,执行后提示符变为 ‘postgres=#’
ALTER USER postgres WITH PASSWORD ‘abc123’ 设置postgres用户密码
\q 退出数据库
切换到root配置一下远程连接。
开启远程访问
vi /var/lib/pgsql/10/data/postgresql.conf
修改#listen_addresses = ‘localhost’ 为 listen_addresses=’*’
当然,此处‘*’也可以改为任何你想开放的服务器IP
信任远程连接
vi /var/lib/pgsql/10/data/pg_hba.conf
修改如下内容,信任指定服务器连接
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.1.2/32(需要连接的服务器IP) trust
远程连接配置完成,由于系统原因,还需要在防火墙中打开相应的端口。
打开防火墙
CentOS 防火墙中内置了PostgreSQL服务,配置文件位置在/usr/lib/firewalld/services/postgresql.xml,我们只需以服务方式将PostgreSQL服务开放即可。
firewall-cmd –add-service=postgresql –permanent 开放postgresql服务
firewall-cmd –reload 重载防火墙
最后一步,不能忘记的,是重启数据库服务,使配置生效。
重启PostgreSQL数据服务
systemctl restart postgresql-10.service
错误:
Job for postgresql-10.service failed because the control process exited with error code. See "systemctl status postgresql-10.service" and "journalctl -xe" for details
- 1
原因:
数据库安装完后没有进行初始化工作
解决:
>/usr/pgsql-10/bin/postgresql-10-setup initdb
- 1
至此,PostgreSQL 10 在CentOS 7上完成基本安装和配置。
下面是postgersSQL的使用,在使用postgres的时候要在postgres用户下使用。
createdb mydb
执行这句的时候回出现很多问题,具体见:doc
下面是常见的一种错误:
createdb: could not connect to database postgres: FATAL: role “joe” does not exist
这个是因为没有以postgres用户执行的原因。
执行SQL语句:
psql mydb
之后就可以像普通关系型数据库一样执行SQL语句了,具体参看doc
CentOS 7 安装、配置、使用 PostgreSQL 10 安装及基础配置的更多相关文章
- PostgreSQL 10.7 linux 主从配置
PostgreSQL 10.7 主从安装 硬件环境 云服务商:华为云 Linux: CentOS7.1 工具:Xshell Xftp IP:114.115.251.168 Port: 5432 543 ...
- 阿里云ECS服务器Linux环境下配置php服务器(一)--基础配置篇
开始安装软件了,我们需要安装的软件有apache,php和MySQL. ps:如果你购买的是北京的服务器,有个安全组需要设置,我全部用的默认设置,暂时还没发现会有什么影响. 首先关闭SELINUX(S ...
- Ubuntu下编译安装postgreSQL 10.5
Ubuntu下编译安装postgreSQL 10.5 ubuntu 16.04 LTS系统postgreSQL 10.5 安装包准备 1.从PostgreSQL官网下载PostgreSQL的安装包 安 ...
- 自己在安装centos 系统时, 是使用英文安装 成功,现在系统语言为英语,如何设置为中文?
作为一个linux菜鸟,遇到的问题可谓真多,在虚拟机VMware上安装好centos系统后,心里甚喜,也连上网络了. 一.遇到的问题 but,火狐浏览器浏览网页出现乱码,也不知道怎么解决?所有的中文都 ...
- MS-DOS 7.10完整安装版(含图文安装程序)
大家知道,要想学习或使用DOS,安装一个DOS并进行实际操作是非常必要的.MS-DOS 7.10是一个非常好且强大实用的操作系统,而且兼容性和性能都十分强.要在系统中安装MS-DOS 7.10,可以使 ...
- Fedora 28 系统基础配置以及常用软件安装方式
实验说明: 很多人说Linux很难用,很难上手,其实不然,倘若不玩游戏,其实很多发行版Linux都可以成为主力系统,就比如本章要讲的 Fedora 28.本章会从镜像来源.系统安装.基础配置和常用软件 ...
- CentOS 6.3下PostgreSQL 的安装与配置
一.简介 PostgreSQL 是一种非常复杂的对象-关系型数据库管理系统(ORDBMS),也是目前功能最强大,特性最丰富和最复杂的自由软件数据库系统.有些特性甚至连商业数据库都不具备.这个起源于伯克 ...
- Linux——CentOS 6.3下PostgreSQL 的安装与配置
一.简介 PostgreSQL 是一种非常复杂的对象-关系型数据库管理系统(ORDBMS),也是目前功能最强大,特性最丰富和最复杂的自由软件数据库系统.有些特性甚至连商业数据库 都不具备.这个起源于伯 ...
- CentOS 7 安装、配置、使用 PostgreSQL 9.5(一)安装及基础配置
一直不知道怎么读这个数据库的名字,在官网上找到了文档.PostgreSQL is pronounced Post-Gres-Q-L. 读音 What is PostgreSQL? How is it ...
随机推荐
- 在pycharm中启动Django服务器
1.要是直接运行manage.py程序的话 会提示一大堆东西,那无非是提示没有传入参数.先打开mange.py,然后再运行,会提示一堆东西,表示没有配置参数.在pycharm右上角点击edit con ...
- red hat enterprise linux 6
i386(32位):http://rhel.ieesee.net/uingei/rhel-server-6.3-i386-dvd.iso迅雷快传:http://kuai.xunlei.com/d/PF ...
- [转]oracle 11g jdbc jar包在哪个文件目录
oracle 11g jdbc jar包在哪个文件目录 一. 如果装了Oracle数据库的话, 大致是这样的目录: D:\oracle\product\11.2.0\client_1\oui\ ...
- Xcode7.3 beta 新功能 https://developer.apple.com/go/?id=xcode-7.3-rn
Xcode7.3 beta 新功能html, body {overflow-x: initial !important;}html { font-size: 14px; } body { margin ...
- [note]Why I haven’t quit my corporate job (yet)
Why I haven't quit my corporate job (yet)html, body {overflow-x: initial !important;}html { font-siz ...
- CentOS6.3升级Python到2.7.3版本
http://www.zhangchun.org/the-centos6-3-upgrade-python-to-2-7-3-version/ 查看python的版本 1 python -V 2 ...
- python3.6使用mysql
因为MySQLdb不支持python3,需要导入pymysql 可以选择pip 安装pymysql,或者pycharm安装 [File] >> [settings] >> [P ...
- java获取classpath以外的路径
最近在使用以前写过的代码生成器(从表名可生成所有的代码)的时候,发现生成的文件都在classpath目录下,所有的文件都得自己拷到工程目录下,于是,想优化一下,取得classpath目录以外的路径,很 ...
- MapReduce教程(一)基于MapReduce框架开发<转>
1 MapReduce编程 1.1 MapReduce简介 MapReduce是一种编程模型,用于大规模数据集(大于1TB)的并行运算,用于解决海量数据的计算问题. MapReduce分成了两个部分: ...
- 设置一个按钮为一个图片,不要border
//设置一个按钮为一个图片,不要border ImageIcon searchIcon = ImageToolkit.loadImageIcon(/search.png"); ImageIc ...