Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mamedshahmaliyev/e594f8fdf33dc7486736ca988d39cf71 to your computer and use it in GitHub Desktop.
Save mamedshahmaliyev/e594f8fdf33dc7486736ca988d39cf71 to your computer and use it in GitHub Desktop.
postgresql
su - postgres
psql
# change user password
ALTER USER user_name WITH PASSWORD 'new_password';
\l #list databases
\c db_name # use database
\dt # list tables
psql DBNAME USERNAME
sudo -u postgres psql
postgres=# create database mydb;
postgres=# create user myuser with encrypted password 'mypass';
postgres=# grant all privileges on database mydb to myuser;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO <username>;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO <username>;
remote access:
postgresql.conf listen_addresses = '*'
pg_hba.conf host all all 0.0.0.0/0 md5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment