Skip to content

Instantly share code, notes, and snippets.

@Dylan0203
Created September 6, 2017 15:31
Show Gist options
  • Select an option

  • Save Dylan0203/e6db3e61dd9b4f792d0ea28705d4d244 to your computer and use it in GitHub Desktop.

Select an option

Save Dylan0203/e6db3e61dd9b4f792d0ea28705d4d244 to your computer and use it in GitHub Desktop.

Revisions

  1. Dylan0203 created this gist Sep 6, 2017.
    30 changes: 30 additions & 0 deletions text.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e


    https://www.cyberciti.biz/faq/howto-add-postgresql-user-account/

    ```
    $ sudo -u postgres psql
    ```

    Create User

    ```
    $ sudo -u postgres createuser <username>
    ```

    Creating Database
    ```
    $ sudo -u postgres createdb <dbname>
    ```

    Giving the user a password
    ```
    $ sudo -u postgres psql
    psql=# alter user <username> with encrypted password '<password>';
    ```

    Granting privileges on database
    ```
    psql=# grant all privileges on database <dbname> to <username> ;
    ```