postgresql路径的简单介绍

linux下修改pgsql的data路径

1. 修改配置文件/etc/postgresql/9.3/main/postgresql.conf

10年的扬中网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站的优势是能够根据用户设备显示端的尺寸不同,自动调整扬中建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“扬中网站设计”,“扬中网站推广”以来,每个客户项目都认真落实执行。

data_directory = '/home/pgdata'

2. 修改data_directory的所有者

chown -R postgres:postgres /home/pgdata

3. 这时候启动会报error

* The PostgreSQL server failed to start. Please check the log output:

2014-11-25 09:55:02 CST FATAL: data directory "/home/pgdata" has group or world access

2014-11-25 09:55:02 CST DETAIL: Permissions should be u=rwx (0700).

根据提示修改数据目录权限

chmod 700 /home/pgdata

4. 启动依然会报错

* The PostgreSQL server failed to start. Please check the log output:

2014-11-25 09:56:17 CST FATAL: "/home/pgdata" is not a valid data directory

2014-11-25 09:56:17 CST DETAIL: File "/home/pgdata/PG_VERSION" is missing.

把默认数据目录的东西拷贝过来

cp -r /var/lib/postgresql/9.3/main/* /home/pgdata

5. 启动 service postgresql start

虚拟机中如何安装PostgreSQL数据库?

配置PostgreSQL对应的yum源

使用命令:dnf install -y ,获取yum配置文件。

安装PostgreSQL13对应的rpm包

一般来说PostgreSQL需要安装的包包括:

依赖库包:postgresql13-libs.x86_64

模块分布式:postgresql13-contrib.x86_64

客户端:postgresql13.x86_64

服务端:postgresql13-server.x86_64

创建postgres用户及组

groupadd postgres 创建postgres组

useradd -g postgres创建postgres用户

初始化数据库

安装postgresql数据库后,默认的数据目录为: /var/lib/pgsql/10/data/。但是在实际使用中,我们必须为postgresql数据库指定专用的数据路径。

1、创建指定路径

mkdir -p /data/pgdata

2、修改pgdata的所有者

chown postgres /data/pgdata

3、切换到postgres用户

su - postgres?

4、初始化postgres数据库实例

/usr/pgsql-13/bin/initdb -D /data/pgdata

到这里就安装完成了。

如何设置或更改PostgreSQL数据目录位置

Services Management”即“服务”中停止相应的PostgreSQL服务

方式二:通过命令行“NET STOPpostgresql-x64-9.1”停止相应的PostgreSQL服务Step

2:修改注册表对应键值位置在"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

\postgresql-x64-9.1

\ImagePath

",将“-D”后的目录名修改为新的数据目录位置即可,如果目录路径中含有空格,需要用引号引起。Step 3:数据迁移

拷贝数据至新数据目录,需要注意必须检查用户权限是否可于访问新的数据目录。Step 4:开启PostgreSQL服务

或者使用命令行命令“NETSTARTpostgresql-x64-9.1”[Linux]修改postgresql.conf文件,

data_directory = '

新数据目录名'

,然后重启postgresql服务即可。

修改完毕后,可以用psql命令“showdata_directory”查看当前数据目录

Postgresql存储二进制大数据文件

title: "Postgresql存储二进制大数据文件"

date: 2021-02-02T20:46:31+08:00

draft: true

tags: ['postgres','binary']

author: "dadigang"

author_cn: "大地缸"

personal: " "

如果想把整个文件或图片存储在数据表的一个字段内,该字段可以选择二进制类型,然后将文件按二进制存储起来,文本文件也可以存在text字段内。

示例如下:

二进制类型bytea的操作(在最大值内,有内存限制)

1、 创建表

2、 将文件放到coordinator目录下/mnt/postgresql/coord

通过pg_read_binary_file()函数,插入一张图片- 目录:/mnt/postgresql/coord/1.jpg

3、 也可以调用pg_read _file()将一个文本文件存储在一个text字段内

注意:函数pg_read_binary_file()和pg_read_file()中的路径必须是相对路径,默认路径是coordinator目录下,并且必须在coordinator目录下或者coordinator目录的子目录下。

Name

Return Type

Description

pg_read_file(filename text [, offset bigint, length bigint])

text

Return the contents of a text file

pg_read_binary_file(filename text [, offset bigint, length bigint])

bytea

Return the contents of a file


文章题目:postgresql路径的简单介绍
网页网址:http://lszwz.com/article/dscieie.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款