Abdulrahman AlQallaf

Decluttering my mind into the web ...







PostgreSQL initiation

date posted: 2020-May-25, last edit date: 2020-Jun-01


/*
sudo su - postgres
psql
*/


-- STEP 0 -- revoke privileges for all unspecified users
\l+
revoke all privileges on database <db name> from public;
\l+


-- STEP 1 -- create new user
\du+
create user "<user name>" with encrypted password '<user password>';
\du+


-- STEP 2 -- create new database
\l+
create database "<DB name>";
revoke all privileges on database "<DB name>" from public;
\l+
\connect "<DB name>"
\dt+ *.*


-- STEP 3 -- grant privileges
\l+
grant all privileges on database "<DB name>" to "<user name>";
\l+


/*
exit
psql --host=localhost --username="<user name>" --dbname="<DB name>"
test that you are not be able to connect to other databases
*/

-- STEP 4 -- create new schema
select * from information_schema.schemata;
create schema <schema name>;
select * from information_schema.schemata;





# Post Title Date Posted Last Edit Date
1 New tools for data analysis (ipython-sql and Azure Data Studio) 2021-10-16 2021-10-16
2 How to setup a remote jupyter server 2021-10-13 2021-10-13
3 How to setup ZSH 2021-10-12 2021-10-12
4 Concepts in Data Architecture 2021-05-01 2021-10-16
5 Loading data into PostgreSQL reference 2021-03-19 2021-03-19
6 SQLite <--> Pandas reference 2021-03-15 2021-03-15
7 Creating an automated data mart (in SQL) 2020-07-16 2020-07-16
8 Personal finance management and open banking 2020-07-12 2020-07-12
9 Quick SQL reference 2020-07-03 2020-11-29
10 How to back up Digital Ocean Spaces (S3 compatible storage) 2020-06-07 2020-07-03
11 current post -- PostgreSQL initiation 2020-05-25 2020-06-01