1. 下载postgresql源码
https://www.postgresql.org/ftp/source/
2. 编译安装
./configure --prefix=/Volumes/data/postgresql
make
make install
3. 初始化数据库
./initdb -D ../data
4. 启动 postgresql 数据库
./pg_ctl -D ../data -l logfile start #后台执行
或
./postgres -D ../data #直接运行
5. 创建数据库用户
./createuser odoo -d -P
6. 更新环境变量
vim ~/.bash_profile
export PATH=$PATH:/Volumes/data/postgresql/bin:$PATH
export LD_LIBRARY_PATH=/Volumes/data/postgresql/lib:$LD_LIBRARY_PATH
7. 激活环境变量
source ~/.bash_profile
8. 进入postgresql命令环境
psql -U odoo -d postgres
9. 注意源码安装后,切勿随意移动源码文件夹位置,否则会有可能出现报错
dyld: Library not loaded: /Users/castle/Documents/postgresql13.1/lib/libpq.5.dylib Referenced from: /Users/castle/Documents/postgresql/postgresql13.1/bin/psql Reason: image not found
源码安装postgresql