Last active
July 23, 2021 13:48
-
-
Save mamedshahmaliyev/e594f8fdf33dc7486736ca988d39cf71 to your computer and use it in GitHub Desktop.
postgresql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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