mac使用brew安装postgresql

在您的命令行中运行以下命令:

brew doctor
brew update
安装
在您的命令行中运行以下命令:brew install postgres

你也可以指定版本: brew install postgres@11.17

启动 PostgreSQL 作为服务使用;
brew services start postgresql
停止 PostgreSQL
brew services stop postgresql
如果您卸载 postgresql,那么您可以使用该命令删除其链接;
brew services cleanup

运行命令:createdb 'test'

createuser -s postgres 修复role "postgres" does not exist

brew reinstall readline-仅在需要时

用psql命令测试

使用以下命令连接到您的 postgres:psql

Mac brew 安装Postgres 开机自启动

1.找到homebrew.mxcl.postgresql.plist 文件
mac m1用brew安装postgresql的该文件是在/opt/homebrew/opt/postgresql路径下

2、链接到 ln -s /opt/homebrew/opt/postgresql/homebrew.mxcl.postgresql.plist /Library/LaunchAgents/ 目录下

3、执行 launchctl load /Library/LaunchAgents/homebrew.mxcl.postgresql.plist

4.如果没权限就用sudo加权限

5、重启电脑,查看postgres 进程
ps -ef |grep postgres

posted @   zong涵  阅读(1668)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示