Ken的杂谈
  • Ken的杂谈 (current)
  • 关于
  • 杂谈
    Java Spring Spring Boot Spring Cloud MyBatis C# .NET Core .NET ASP.NET Core ASP.NET ClassLibrary Mono 数据库 MySQL SQL Server 网络 缓存 Web Linux CentOS Ubuntu macOS Nginx Windows ServiceStack JS/JQ 正则 工具 IDE Grafana Exceptions CI/CD Solution 微服务 Arch Docker 杂谈
  • 系列
    Java 快速入门系列教程 Spring Boot 入门教程 Spring Boot 2.x 入门教程 Spring Cloud 入门教程 .NET Core 快速入门教程 ASP.NET Core 2.1 入门教程 CentOS 7 快速上手教程 Ubuntu快速上手入门教程 Hyper-V基础教程 Docker入门教程
  • GitHub

解决macOS下PostgreSQL安装失败问题

Exceptions 数据库 macOS @ 2023-02-05 12:39:35 · 阅读:(295)

一、现象与原因

1、问题现象

Problem running post-install step. Installation may not complete correctly The database cluster initialisation failed.
image.png

2、原因解析

PostgreSQL默认会把相关目录所有者设置为postgres,缺少此账户就会导致安装过程中chown命令执行失败,从而导致安装失败

二、解决办法

1、完全卸载PostgreSQL

# 打开卸载App,路径中的15是PostgreSQL的版本,根据自己的安装情况替换即可
open /Library/PostgreSQL/15/uninstall-postgresql.app/

# 删除PostgreSQL目录
sudo rm -rf /Library/PostgreSQL/

# 删除配置文件
sudo rm /etc/postgres-reg.ini

2、初始化PostgreSQL用户

使用dscl命令创建用户:postgres

# 创建用户并指定Shell
sudo dscl . -create /Users/postgres UserShell /bin/bash

# 设置用户ID(需要唯一)、显示名称
sudo dscl . -create /Users/postgres UniqueID "5001"
sudo dscl . -create /Users/postgres RealName "postgres"

# 将用户设置为管理员
sudo dscl . -create /Users/postgres PrimaryGroupID 80

# 修改密码
sudo dscl . -passwd /Users/postgres yourpassword

如果你习惯使用图形化界面操作,可以通过菜单:系统设置->用户与群租->添加账户,添加postgres账户
image.png

3、重新安装

image.png


Ken的杂谈

本文由 ken.io 创作,采用CC BY 3.0 CN协议 进行许可。 可自由转载、引用、甚至修改,但需署名作者且注明出处。

Exceptions 数据库 macOS

随笔目录


    © Copyright 2012-2023 Ken的杂谈

    豫ICP备10025012号-1

    ASP.NET Core(6.0) on Linux