Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Created June 4, 2011 20:06
Show Gist options
  • Save xeoncross/1008297 to your computer and use it in GitHub Desktop.
Save xeoncross/1008297 to your computer and use it in GitHub Desktop.
PostgreSQL Commands
# install postgresql
$ sudo apt-get install postgresql
# Login as postgres user
$ sudo -u postgres psql postgres
# Set a password for the "postgres" database role using the command:
$ \password postgres
# Creating a new PostgreSQL user
$ sudo -u postgres createuser -d -R -P <new username>
# Create a new database owned by <username>
$ sudo -u postgres createdb -O <usename> <database name>
# Executing an SQL file
$ psql -f <filename> <database name> <username>
# Removing a database
$ dropdb -U <username> <database name>
# Removing a PostgreSQL user
$ sudo -u postgres dropuser <usernamen>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment