DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Connor Bode
Connor Bode

Posted on

Creating a Postgres database + user

Let's create a new database + a user to access it.

  1. su - postgres to get a shell as the postgres user
  2. psql to get a postgres shell
  3. create database db_name; to create the database
  4. create user user_name with encrypted password 'user_password'; to create the user
  5. grant all privileges on database db_name to user_name; to grant the user all privileges on the database.

That's it really.


As a brief aside, I like to write my SQL in all lowercase. I find it really annoying to use all caps for statements and all lowercase for variables, which seems to be a syntactic standard with no real benefit? Anyone else do this / have a comment on this?


Follow me on dev.to for more code blurbs, or on Twitter @connorbode

Top comments (0)

5 Websites To Learn Frontend Web Development Faster

In this article, Bentil Shadrack has curated 5 resourceful sites that will help you better you web development skills really fast.