首先确保你的mac上已经装有homebrew,可以通过命令行查询brew版本
brew info #查看homebrew的相关信息
brew help #查看homebrew相关命令
使用homebrew安装psql(postgresql,一下简称psql)
brew install postgresql

查看psql版本
pg_ctl -V
初始化psql数据库
initdb /usr/local/var/postgres
可能会出现错误

解决办法,如提示解决即可
#remove or empty the directory "/usr/local/var/postgres"
#run initdb with an argument other than "...."
cd /usr/local/var/postgres
rm -r * #清空当前文件夹下的所有文件
#再次运行就可
initdb /usr/local/var/postgres
启动数据库
#方法一

本文介绍了如何在macOS上利用homebrew来安装、初始化、启动postgresql数据库,包括解决初始化过程中的错误、创建用户和数据库,以及如何卸载postgresql。详细步骤包括检查homebrew、安装postgresql、启动服务、创建用户和数据库、登录数据库,以及卸载数据库的完整流程。
最低0.47元/天 解锁文章
118

被折叠的 条评论
为什么被折叠?



