Skip to content

Instantly share code, notes, and snippets.

@limcheekin
Last active June 12, 2025 22:57
Show Gist options
  • Select an option

  • Save limcheekin/d7a7a59104a0e5058cfb09a475a32b44 to your computer and use it in GitHub Desktop.

Select an option

Save limcheekin/d7a7a59104a0e5058cfb09a475a32b44 to your computer and use it in GitHub Desktop.
Create New User and New Database for the PostgreSQL
CREATE ROLE new_user WITH LOGIN PASSWORD 'your_secure_password';
CREATE DATABASE new_database OWNER new_user;
GRANT ALL PRIVILEGES ON DATABASE new_database TO new_user;
-- Example:
-- CREATE ROLE talking_book WITH LOGIN PASSWORD 'your_secure_password';
-- CREATE DATABASE think_and_grow_rich OWNER talking_book;
-- GRANT ALL PRIVILEGES ON DATABASE think_and_grow_rich TO talking_book;
-- #psql -U talking_book -d think_and_grow_rich
-- To forcefully drop it—even with active connections
DROP DATABASE new_database WITH (FORCE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment