Skip to content

Instantly share code, notes, and snippets.

@rezwan-hossain
Last active August 6, 2017 20:27
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 rezwan-hossain/431df2fba1d33cecc01bbf3ca8d80b24 to your computer and use it in GitHub Desktop.
Save rezwan-hossain/431df2fba1d33cecc01bbf3ca8d80b24 to your computer and use it in GitHub Desktop.
PostgreSQL and pgAdmin setup
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
Switching Over to the postgres Account
The installation procedure created a user account called postgres that is associated with the default Postgres role.
In order to use Postgres, we can log into that account.
Switch over to the postgres account on your server by typing:
sudo -i -u postgres
You can now access a Postgres prompt immediately by typing:
psql
Exit out of the PostgreSQL prompt by typing:
\q
How to Back Up a PostgreSQL Database Using pg_dump
sudo su - postgres
pg_dump databaseName > somthing.sql
this are basic thing you can do more search on the internet
change password
sudo -u postgres psql
ALTER USER postgres PASSWORD 'my_postgres_password';
After the changeing the password you must restart server
/etc/init.d/postgresql restart ; //{ Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ..]
}
pgAdmin4 desktop mode-in-ubuntu-16-04
First, create a virtual environment:
sudo apt-get install virtualenv python-pip libpq-dev
Now, go to pgadmin4 and activate it:
cd pgadmin4
source bin/activate
Download the pgadmin4:
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.4/pip/pgadmin4-1.4-py2.py3-none-any.whl
you can find letest version on pgAdmin website; my case my version is 4.1.4
Now install pgadmin4:
pip install pgadmin4-1.4-py2.py3-none-any.whl
Do activate:
cd ~/pgadmin4
source bin/activate
Execute require python script:
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
Add email and password and done
#final
start the pgAdmin server and go to localhost:5050 . click on server . if you dont see any database create new server
give name of a server. In connection tab give Host name "localhost", port: 5432 , Maintenance database: postgress
username: 'your postgres username' my case postgres password: 'your postgrest password'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment