Skip to content

Instantly share code, notes, and snippets.

@rponte
Last active June 17, 2020 20:14
Show Gist options
  • Select an option

  • Save rponte/f85a4269f3fd2f3a8373b3306f22fe3c to your computer and use it in GitHub Desktop.

Select an option

Save rponte/f85a4269f3fd2f3a8373b3306f22fe3c to your computer and use it in GitHub Desktop.
PostgreSQL: Creating a new user and database
-- Create the database user
CREATE USER rponte WITH PASSWORD '123';
-- Create the database
CREATE DATABASE mydb WITH OWNER = rponte
ENCODING = 'UTF8'
LC_CTYPE = 'en_US.UTF-8'
LC_COLLATE = 'en_US.UTF-8'
TEMPLATE = template0;
-- Grant permissions for the created user
GRANT ALL PRIVILEGES ON DATABASE mydb TO rponte;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment