PostgreSQL

Connect via psql

$ psql -h <hostname> -p <port> -U <user> <db_name>

Create User and DB

$ psql -U <username>
DROP DATABASE <dbname>;
CREATE USER <username> WITH PASSWORD '<password>';
CREATE DATABASE <dbname> OWNER <username>;
CREATE DATABASE optimization OWNER tactical;

Drop DB

$ dropdb -U <username> <dbname>

Show schemas - psql cli

\dn

Show tables - psql cli

\dt

Show tables in a schema

\dt <schema_name>.

Quit postgres prompt

postgres-> \q

Generate dump

pg_dump -h <server_hostname> -U <username>  -f db.dump <db_name>

Import .dump

psql -h <server_hostname> -U <user> <db_name> < <PATH TO DUMP>

Redis

Flush all keys

$ redis-cli -c -h $redis_endpoint -p $port flushall

MongoDB

Ref: Mongo Shell reference

Connect to a DB

$ mongo --host localhost -u <username> --authenticationDatabase <dbname> -p <paassword>

Switch/Use DB

> use admin;
switched to db admin

Show collections in DB

> show collections;
mycollection
system.users
system.version