Skip to content

Instantly share code, notes, and snippets.

@edwardstock
Last active June 23, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardstock/56f6b929e70cbf308d04a2a636b3e1c8 to your computer and use it in GitHub Desktop.
Save edwardstock/56f6b929e70cbf308d04a2a636b3e1c8 to your computer and use it in GitHub Desktop.
# init new database
# dir: /usr/pgsql-$VERS
initdb -A trust --auth-local=trust --encoding=UTF8 --pgdata=/var/pgsql10
# dump old database (-O [--no-owners] - drops owners assignment, by default in new db's rights will grant to importer)
pg_dumpall -O -U postgres > /var/db.out
# import database dump
psql -f db.out postgres
# create user
createuser -d -l -P USERNAME
# createdb to user
createdb --encoding=UTF8 --owner=USERNAME DBNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment