作者: ZoeyMiao | 来源:发表于2017-04-04 17:28 被阅读0次

    【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;     授权建立数据库

    相关文章

      网友评论

          本文标题:

          本文链接:https://www.haomeiwen.com/subject/hxuebttx.html