Let's create a new database + a user to access it.
-
su - postgres
to get a shell as the postgres user -
psql
to get a postgres shell -
create database db_name;
to create the database -
create user user_name with encrypted password 'user_password';
to create the user -
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)