【Step1】: 在Mac上安装PostgreSQL

参考:https://launchschool.com/blog/how-to-install-postgresql-on-a-mac

0: 前提需要:homebrew安装

1: brew update

确认计算机上的homebrew是最新版本

2: brew install postgres

安装postgres 一般会得到:🍺/usr/local/Cellar/postgresql/9.5.5: 3,154 files, 35.1M

3: brew tap homebrew/services 安装tap services 

4: brew services start postgresql 在背景中启动Postgres,相似还可以将 start改成stop和restart进行关闭和重启

5: Basic Practice and test of Installation

- 创建数据库 createdb mydb

- 删除数据库  dropdb mydb

- 访问数据库  psql (enter, edit and execute SQL demands)

出现界面可能为 mydb =# 意味着  目前的状态为superuser

6: Some basic SQL commands to play with

- SELECT version();

- SELECT current_date;

- SELECT 2+2;

7: Some internal commands

- \h (get help)

- \q (get out of psql)

- \? (for more internal commands)

8: Configuration     psql postgres

- \du  : list all users

9: Create Role 

Create ROLE username WITH  password 'your pws here ' [OPTIONS]

ALTER ROLE username CREATEDB;     授权建立数据库

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

推荐阅读更多精彩内容