Skip to content

Instantly share code, notes, and snippets.

@susemeee
Created April 6, 2023 06:47
Show Gist options
  • Save susemeee/85cf3dc29e5f07d60a8fc587c37e6b10 to your computer and use it in GitHub Desktop.
Save susemeee/85cf3dc29e5f07d60a8fc587c37e6b10 to your computer and use it in GitHub Desktop.
PostgreSQL Create new user with database
sudo vim /etc/postgresql/12/main/pg_hba.conf
host    <db_name>             <user_name>             0.0.0.0/0               password
:wq
sudo -u postgres psql
CREATE DATABASE <db_name>;
CREATE USER <user_name> WITH ENCRYPTED PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE <db_name> TO <user_name>;
SELECT pg_reload_conf();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment