我的本地环境是mac,用homebrew安装,后期使用比直接用官网安装包安装来的方便:
brew install postgresql
brew install slowhttptest
brew services start postgresql
initdb /usr/local/var/postgres
sudo chmod 775 /usr/local/var/postgres
sudo chown wayson /usr/local/var/postgres
initdb /usr/local/var/postgres
rm -rf /usr/local/var/postgres
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l logfile start
createdb
psql 进入控制台
接下来就需要创建用户,最好创建一下以postgres用户。

CREATE USER postgres WITH PASSWORD 'xxxx';#这里的密码”xxxx“由你自己来设置
删除默认生成的postgres数据库:

DROP DATABASE postgres;
创建属于用户postgres的数据库,名字也叫postgres,当然你也可以取名叫别的。

CREATE DATABASE postgres OWNER postgres;
将数据库权限赋予为postgres用户:

GRANT ALL PRIVILEGES ON DATABASE postgres to postgres;
再给用户postgres用户添加创建数据库的属性,可以使用postgres作为数据库的登录用户并管理数据库。

ALTER ROLE postgres CREATEDB;

这样Mac上的PostgreSQL就基本设置好了。

————————————————
版权声明:本文为CSDN博主「MaineCoon」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Brookekitty/article/details/106192977

标签: postgresql

添加新评论