赞
踩
参考链接:https://www.cnblogs.com/Simple-Small/p/12882594.html
按照大佬的安装过程安装既可,中途会遇到以下报错
Problem running post-install step. Installation may not complete correctly The database cluster initialisation failed.
我根据大佬的解决方案未解决该报错,并尝试了诸多方法,降低版本等都不可行;
在 stack overflow 相关问题的解决方案,我选择放弃dmg方式的傻瓜安装,采用 brew 的安装方式
首先要在mac上安装最新的 Homebrew
如果没有安装可以在 terminal 键入以下命令安装,安装失败大概率是连不上服务器,可以采用国内镜像
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
安装成功或已安装的用户更新到最新 brew
brew update
检查 brew 安装情况
➜ ~ git:(master) ✗ brew -v
Homebrew 3.5.9
Homebrew/homebrew-core (git revision a160ff052d2; last commit 2022-08-11)
Homebrew/homebrew-cask (git revision ba90c5912b6; last commit 2022-08-10)
查看当前 brew 下的安装列表
➜ ~ git:(master) ✗ brew list
==> Formulae
bdw-gc icu4c nettle
boost isl node
brotli krb5 npth
c-ares libassuan openssl@1.1
...
在 terminal 执行以下命令
➜ ~ git:(master) ✗ brew install postgresql
error: could not lock config file .git/config: Permission denied
error: could not lock config file .git/config: Permission denied
fatal: not in a git directory
Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/krb5-1.20.arm
######################################################################## 100.0%
==> Downloading https://mirrors.cloud.tencent.com/homebrew-bottles/postgresql-14
######################################################################## 100.0%
==> Installing dependencies for postgresql: krb5
==> Installing postgresql dependency: krb5
...
检查安装结果
➜ ~ git:(master) ✗ psql -V
psql (PostgreSQL) 14.4
检查服务列表,显示 PostgreSQL 未启动
➜ ~ git:(master) ✗ brew services list
Name Status User File
postgresql none
unbound none
启动 PostgreSQL
➜ ~ git:(master) ✗ brew services start postgresql
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
检查执行结果
➜ ~ git:(master) ✗ brew services list
Name Status User File
postgresql error 256 user ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
unbound none
只要不是 none 就代表 已启动
关闭 PostgreSQL
➜ ~ git:(master) ✗ brew services stop postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
createuser 用户名 -P
➜ ~ git:(master) ✗ createdb 数据库名 -O 用户名 -E UTF8 -e
检查现有用户及数据库
➜ ~ git:(master) ✗ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------------+----------+---------+-------+-------------------
mydb | mypsql | UTF8 | C | C |
postgres | user | UTF8 | C | C |
template0 | user | UTF8 | C | C | =c/user +
| | | | | user=CTc/user
template1 | user | UTF8 | C | C | =c/user +
| | | | | user=CTc/user
(4 rows)
➜ ~ git:(master) ✗ psql -U mypsql -d mydb -h 127.0.0.1
psql (14.4)
Type "help" for help.
mydb=> </span>q
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。