Mac安装postgreSQL

安装

使用brew方式安装

brew install postgresql

启动

启动服务:

①创建postgreSql数据库:

initdb /usr/local/var/postgres

(如果提示directory "/usr/local/var/postgres" exists but is not empty),则需要清空这个目录使用如下命令rm -rf /usr/local/var/postgres

②启动服务

pg_ctl -D /usr/local/var/postgres -l logfile start

③创建用户

//这时会需要输入密码  自行输入即可。
createuser -d -a -P postgres 

④关闭服务

pg_ctl -D /usr/local/var/postgres -l logfile stop

其他操作

①创建用户

sudo -s -u postgres
psql
postgres# CREATE USER test WITH PASSWORD '123456';
postgres# CREATE DATABASE testdata;
postgres# GRANT ALL PRIVILEGES ON DATABASE testdata to test;

②修改密码

alter user postgres with password '123456';

允许远程访问

修改pg_hba.conf配置:

vim cd /usr/local/var/postgres/pg_hba.conf

修改postgresql.conf

vim cd /usr/local/var/postgres/postgresql.conf
image.png

修改端口也在postgresql.conf中,修改完成需要重启。

以上为基本操作,更多操作请自行百度。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容