Skip to content

Instantly share code, notes, and snippets.

View jackie-do's full-sized avatar
🎯
Focusing

Huy Do jackie-do

🎯
Focusing
View GitHub Profile
@jackie-do
jackie-do / [postgresql]_set_up_read_only_user.md
Last active January 4, 2018 06:50
Set up a read-only user for Postgresql
  1. Create a linux user and set password
sudo adduser read_access

.. then enter your password for this user

  1. Limit permission for the user (option) .. normally, this user only has root permission on it's directory. (/home/read_access)

  2. Set read-only role for this user to use Postgresql

@jackie-do
jackie-do / [postgresql]_dump_and_restore.md
Last active January 4, 2018 06:51
dump and restore a table
PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser -d mydb -t mytable > mydb.dump

=== RESTORE ===

psql -U boxatwork_newqa -d boxatwork_newqa -1 -f ../../../boxie24_production/shared/db_bk/store_blog_categories_april_24.dump

psql -U boxatwork_newqa -d boxatwork_newqa -1 -f store_blog_categories_april_24.dump
@jackie-do
jackie-do / restore_database_in_docker.md
Last active November 14, 2017 11:14
Restore a postgres database in a docker container
  1. Run the database container only. "docker container start [container name]"

  2. Connect pgAdmin to the docker container

  • Check port of the container, for example: "0.0.0.0:5432->5432/tcp"
  • Create a new connection on pgAdmn: "0.0.0.0:5432"
  1. Remove the old database
# initialization file (not found)