postgreSQL16.6源码安装

news2025/3/18 20:53:07

1.获取源码

从PostgreSQL: File Browser获取tar.bz2或者tar.gz源码

2.解压

tar xf postgresql-version.tar.bz2

root@hwz-VMware-Virtual-Platform:/usr/local# tar xf postgresql-16.6.tar.bz2
root@hwz-VMware-Virtual-Platform:/usr/local# ll
总计 24324
drwxr-xr-x 12 root root     4096  2月  6 11:35 ./
drwxr-xr-x 12 root root     4096 10月  9 21:16 ../
drwxr-xr-x  2 root root     4096 10月  9 21:16 bin/
drwxr-xr-x  2 root root     4096 10月  9 21:16 etc/
drwxr-xr-x  2 root root     4096 10月  9 21:16 games/
drwxr-xr-x  2 root root     4096 10月  9 21:16 include/
drwxr-xr-x  3 root root     4096 10月  9 21:16 lib/
drwxr-xr-x  2 root root     4096 10月  9 21:16 libexec/
lrwxrwxrwx  1 root root        9 10月  9 21:16 man -> share/man/
drwxrwxrwx  6 1107 1107     4096 11月 19 04:48 postgresql-16.6/
-rw-r--r--  1 root root 24856956  2月  6 11:34 postgresql-16.6.tar.bz2
drwxr-xr-x  2 root root     4096 10月  9 21:16 sbin/
drwxr-xr-x  7 root root     4096 10月  9 21:19 share/
drwxr-xr-x  2 root root     4096 10月  9 21:16 src/

3.编译构建程序

root@hwz-VMware-Virtual-Platform:/usr/local# cd postgresql-16.6/
root@hwz-VMware-Virtual-Platform:/usr/local/postgresql-16.6# ./configure --prefix=/usr/local/pgsql16

可能会缺少库,按需安装即可 

make&make install

编译后生成目录

root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# ll
总计 24
drwxr-xr-x  6 root root 4096  2月  7 09:04 ./
drwxr-xr-x 13 root root 4096  2月  7 09:04 ../
drwxr-xr-x  2 root root 4096  2月  7 09:04 bin/
drwxr-xr-x  6 root root 4096  2月  7 09:04 include/
drwxr-xr-x  4 root root 4096  2月  7 09:04 lib/
drwxr-xr-x  6 root root 4096  2月  7 09:04 share/

4.初始化数据库

 先增加一个postgresql用户

useradd postgres
passwd postgres

创建数据目录并让它属于postgres用户

root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# useradd -m postgres
root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# chown postgres . /pgdata/16/data

官方useradd postgres 不加-m参数 Ubuntu可能不会创建用户家目录

root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# su - postgres
postgres@hwz-VMware-Virtual-Platform:~$ ll

这种前面只有$是因为该用户shell为/bin/sh,需要改为/bin/bash 

 4.1 设置环境变量

postgres@hwz-VMware-Virtual-Platform:~$ vim .bash_profile
export PGDATA=/pgdata/16/data
export LANG=en_US.utf8
export PGHOME=/usr/local/pgsql16
export
LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres

测试是否成功

postgres@hwz-VMware-Virtual-Platform:~$ psql --version
psql (PostgreSQL) 16.

 4.2 初始化

postgres@hwz-VMware-Virtual-Platform:~$ initdb -D /pgdata/16/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

initdb: error: invalid locale settings; check LANG and LC_* environment variables

如果出现这个错误是因为 当前用户环境使用的编码和系统编码不一致

postgres@hwz-VMware-Virtual-Platform:~$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

 查看系统编码

postgres@hwz-VMware-Virtual-Platform:~$ vim /etc/locale.conf

LANG=zh_CN.UTF-8

系统用的CN的UTF-8,用户环境是US的UTF-8

现在修改用户环境的编码为CN UTF-8

postgres@hwz-VMware-Virtual-Platform:~$ vim .bashrc

 后面添加

export LC_ALL="zh_CN.UTF-8"

postgres@hwz-VMware-Virtual-Platform:~$ source .bashrc 
postgres@hwz-VMware-Virtual-Platform:~$ locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=zh_CN.UTF-8

 重新初始化成功

postgres@hwz-VMware-Virtual-Platform:~$ initdb -D /pgdata/16/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "zh_CN.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple".

Data page checksums are disabled.

fixing permissions on existing directory /pgdata/16/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Shanghai
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /pgdata/16/data/ -l logfile start

 5.启动数据库

postgres@hwz-VMware-Virtual-Platform:~$ pg_ctl -D/pgdata/16/data/ -l logfile start
waiting for server to start.... done
server started

 查看运行状态

postgres@hwz-VMware-Virtual-Platform:~$ pg_ctl status
pg_ctl: server is running (PID: 94176)
/usr/local/pgsql16/bin/postgres "-D" "/pgdata/16/data"

 6.测试

postgres@hwz-VMware-Virtual-Platform:~$ createdb test
postgres@hwz-VMware-Virtual-Platform:~$ psql test
psql (16.6)
Type "help" for help.

test=# \l
                                                       List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | ICU Locale | ICU Rules |   Access privileges   
-----------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------
 hwz2      | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | 
 postgres  | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | 
 template0 | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +
           |          |          |                 |             |             |            |           | postgres=CTc/postgres
 template1 | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +
           |          |          |                 |             |             |            |           | postgres=CTc/postgres
 test      | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | 
(5 rows)

test=# create table user(id int, name varchar(255));
ERROR:  syntax error at or near "user"
LINE 1: create table user(id int, name varchar(255));
                     ^
test=# create table user1(id int, name varchar(255));
CREATE TABLE
test=# insert into user1 values(1,'hwz'),(2,'www');
INSERT 0 2
test=# select * from user1
test-# ;
 id | name 
----+------
  1 | hwz
  2 | www
(2 rows)

test=# \q
postgres@hwz-VMware-Virtual-Platform:~$

7.关闭数据库

postgres@hwz-VMware-Virtual-Platform:~$ pg_ctl -D /pgdata/16/data/ stop
waiting for server to shut down.... done
server stopped

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2296632.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

树莓派上 基于Opencv 实现人脸检测与人脸识别

一,需求 基于树莓派4b,usb1080p摄像头,实现人脸检测与人脸识别。尝试了海陵科的模组和百度的sdk。海陵科的模组无法录入人脸,浪费了100多块钱。百度的sdk 在树莓派上也无法录入人脸,官方解决不了。最后只能用opencv自…

mac下dify+deepseek部署,实现私人知识库

目前deepseek 十分火爆,本地部署实现私有知识库,帮助自己日常工作,上一篇使用工具cherry studio可以做到私人知识库。今天学习了一下,使用Dify链接deepseek,实现私人知识库,也非常不错,这里分享…

CSS 实现下拉菜单效果实例解析

1. 引言 在 Web 开发过程中,下拉菜单是一种常见且十分实用的交互组件。很多前端教程都提供过简单的下拉菜单示例,本文将以一个简洁的实例为出发点,从 HTML 结构、CSS 样式以及整体交互逻辑三个层面进行详细解析,帮助大家理解纯 C…

x64、aarch64、arm与RISC-V64:详解四种处理器架构

x64、aarch64、arm与RISC-V64:详解四种处理器架构 x64架构aarch64架构ARM架构RISC-V64架构总结与展望在计算机科学领域,处理器架构是构建计算机系统的基石,它决定了计算机如何执行指令、管理内存和处理数据。x64、aarch64、arm与RISC-V64是当前主流的四种处理器架构,它们在…

Java使用aspose实现pdf转word

Java使用aspose实现pdf转word 一、下载aspose-pdf-21.6.jar包【下载地址】&#xff0c;存放目录结构如图&#xff1b;配置pom.xml。 <!--pdf to word--> <dependency><groupId>com.aspose</groupId><artifactId>aspose-pdf</artifactId>…

国产编辑器EverEdit - 迷你查找

1 迷你查找 1.1 应用场景 某些场景下&#xff0c;用户不希望调出复杂的查找对话框&#xff0c;此时可以使用迷你查找窗口。 1.2 使用方法 选择主菜单查找 -> 迷你查找&#xff0c;或使用快捷键Ctrl Alt F&#xff0c;会在右上角弹出迷你查找窗口&#xff0c;如下图所示…

嵌入式音视频开发(一)ffmpeg框架及内核解析

系列文章目录 嵌入式音视频开发&#xff08;零&#xff09;移植ffmpeg及推流测试 嵌入式音视频开发&#xff08;一&#xff09;ffmpeg框架及内核解析 文章目录 系列文章目录前言一、ffmpeg的内核1.1 框架解析1.2 内核解析1.3 FFmpeg内部数据流1.3.1 典型的解码流程1.3.2 典型的…

javaEE-11.javaScript入门

目录 一.什么是javaScript 二.快速实现 三.JS引入方式 1.行内引入: 2.内部引入: 3.外部引入: 四.基础语法 1.变量 变量命名规则: 2.数据类型 3.运算符 五.JS对象 1.数组 创建数组: 2.操作数组 3.函数 函数注意事项: 函数参数: 4.对象 1.使用字面量 创建对象:…

畅游Diffusion数字人(16):由音乐驱动跳舞视频生成

畅游Diffusion数字人(0):专栏文章导航 前言:从Pose到跳舞视频生成的工作非常多,但是还没有直接从音乐驱动生成的工作。最近字节跳动提出了MuseDance,无需复杂的动作引导输入(如姿势或深度序列),从而使不同专业水平的用户都能轻松进行灵活且富有创意的视频生成。 目录 贡…

DeepSeek 助力 Vue 开发:打造丝滑的步骤条

前言&#xff1a;哈喽&#xff0c;大家好&#xff0c;今天给大家分享一篇文章&#xff01;并提供具体代码帮助大家深入理解&#xff0c;彻底掌握&#xff01;创作不易&#xff0c;如果能帮助到大家或者给大家一些灵感和启发&#xff0c;欢迎收藏关注哦 &#x1f495; 目录 Deep…

领略算法真谛:差分

嘿&#xff0c;各位技术潮人&#xff01;好久不见甚是想念。生活就像一场奇妙冒险&#xff0c;而编程就是那把超酷的万能钥匙。此刻&#xff0c;阳光洒在键盘上&#xff0c;灵感在指尖跳跃&#xff0c;让我们抛开一切束缚&#xff0c;给平淡日子加点料&#xff0c;注入满满的pa…

【图片转换PDF】多个文件夹里图片逐个批量转换成多个pdf软件,子文件夹单独合并转换,子文件夹单独批量转换,基于Py的解决方案

建筑设计公司在项目执行过程中&#xff0c;会产生大量的设计图纸、效果图、实景照片等图片资料。这些资料按照项目名称、阶段、专业等维度存放在多个文件夹和子文件夹中。 操作需求&#xff1a;为了方便内部管理和向客户交付完整的设计方案&#xff0c;公司需要将每个项目文件…

在Linux上如何让ollama在GPU上运行模型

之前一直在 Mac 上使用 ollama 所以没注意&#xff0c;最近在 Ubuntu 上运行发现一直在 CPU 上跑。我一开始以为是超显存了&#xff0c;因为 Mac 上如果超内存的话&#xff0c;那么就只用 CPU&#xff0c;但是我发现 Llama3.2 3B 只占用 3GB&#xff0c;这远没有超。看了一下命…

程序诗篇里的灵动笔触:指针绘就数据的梦幻蓝图<8>

大家好啊&#xff0c;我是小象٩(๑ω๑)۶ 我的博客&#xff1a;Xiao Xiangζั͡ޓއއ 很高兴见到大家&#xff0c;希望能够和大家一起交流学习&#xff0c;共同进步。 今天我们复习前面学习的指针知识 目录 关于指针数组和数组指针的区别指针数组&#xff08;Array of Poi…

快速集成DeepSeek到项目

DeepSeek API-KEY 获取 登录DeekSeek 官网&#xff0c;进入API 开放平台 2. 创建API-KEY 复制API-KEY进行保存&#xff0c;后期API调用使用 项目中集成DeepSeek 这里只展示部分核心代码&#xff0c;具体请查看源码orange-ai-deepseek-biz-starter Slf4j AllArgsConstructo…

DeepSeek做赛车游戏

赛车模型 2D生成图片 任意AI图片软件SD&#xff0c;MJ 图片生成3D模型 车身 车轮 场景 Rodin,Tripo和Meshy 询问deepSeek如何开发 拷贝代码 将汽车运行代码拖到汽车上 再让AI写个摄像头跟随代码 再去提问deepseek控制轮胎和一些处理细节

未来替代手机的产品,而非手机的本身

替代手机的产品包括以下几种&#xff1a; 可穿戴设备&#xff1a;智能手表、智能眼镜等可穿戴设备可以提供类似手机的功能&#xff0c;如通话、信息推送、浏览网页等。 虚拟现实&#xff08;VR&#xff09;技术&#xff1a;通过佩戴VR头显&#xff0c;用户可以进行语音通话、发…

uniapp开发微信小程序请求超时设置【亲测有效】

在Hbuilderx中 使用uniapp开发微信小程序时 封装请求方法 请求代码如下 function requestFun(app) {// get请求app.config.globalProperties._get function(path, data, success, fail, complete) {data data || {};data.token uni.getStorageSync(token) || ;uni.request…

deepseek本地部署-linux

1、官网推荐安装方法&#xff08;使用脚本&#xff0c;我绕不过github&#xff0c;未采用&#xff09; 登录ollama下载网站https://ollama.com/download/linux&#xff0c;linux下有下载脚本。 正常来说&#xff0c;在OS系统下直接执行脚本即可。 2、手动安装方法 2.1获取ol…

vite + axios 代理不起作用 404 无效

vite axios 代理不起作用 先看官方示例 export default defineConfig({server: {proxy: {// 字符串简写写法/foo: http://localhost:4567,// 选项写法/api: {target: http://jsonplaceholder.typicode.com,changeOrigin: true,rewrite: (path) > path.replace(/^\/api/, )…