install pgAdmin

Published onesixx on

 

Container

 

https://www.pgadmin.org/download/pgadmin-4-container/
 
|⇒ docker pull dpage/pgadmin4
|⇒ docker run -p 5050:5050 \ 
-e "[email protected]" \
-e "PGADMIN_DEFAULT_PASSWORD=passw0rd" \
-d dpage/pgadmin4
|⇒ docker ps
CONTAINER ID        IMAGE               COMMAND                 CREATED             STATUS              
87e823c530b0        dpage/pgadmin4      "/bin/bash /entry.sh"   2 minutes ago       Up 2 minutes
PORTS                                     NAMES
80/tcp, 443/tcp, 0.0.0.0:5050->5050/tcp   hungry_lamport
➜ docker inspect 87e823c530b0 | grep IPAddress
            "SecondaryIPAddresses": null,
            "IPAddress": "172.17.0.2",
                    "IPAddress": "172.17.0.2",

Source Code

 
 
https://www.pgadmin.org/

DB설정

모든 IP(*)에서 5432 포트 접근 가능하도록 설정

|⇒ sudo vi /etc/postgresql/10/main/postgresql.conf
# CONNECTIONS AND AUTHENTICATION
listen_addresses = '*'

모든 IP(0.0.0.0/0)에서 모든 DB(all)에 대해 모든 계정(all)으로 로그인 허용

|⇒ sudo vi /etc/postgresql/10/main/pg_hba.conf
host    all             all             0.0.0.0/0               md5

PostgreSQL 재시작 후 LISTEN 포트 확인

|⇒ sudo netstat -tnlp | grep postgres
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      25560/postgres  
tcp6       0      0 :::5432                 :::*                    LISTEN      25560/postgres

 

설치

https://kiahosseini.github.io/help/2016/10/18/installing-pgadmin4-ubuntu-16.04.html

 pgAdmin 4     2017-07-13 – pgAdmin 4 v1.6 released

1. 설치전 환경 확인

python설치 확인

~|⇒ which python
/Users/onesixx/.pyenv/shims/python

~|⇒ python -V
Python 2.7.12

~|⇒ python3 -V
Python 3.5.2

~|⇒ pyenv versions
* system (set by /Users/onesixx/.pyenv/version)
  2.7.13
  3.6.1
  3.6.1/envs/tensorflowProject
  tensorflowProject

~|⇒ pyenv version 
system (set by /Users/onesixx/.pyenv/version)

pip 설치 확인

~|⇒ pip -V
pip 9.0.1 from /Users/onesixx/.local/lib/python2.7/site-packages (python 2.7)

필요팩키지 설치 확인 ( libpq-dev)

~|⇒ dpkg -l  | grep libpq 
ii  libpq5:amd64      9.5.7-0ubuntu0.16.04      amd64    PostgreSQL C client library

Virtualenv  생성

~|⇒ pyenv virtualenv system pgadmin4
New python executable in /Users/onesixx/.pyenv/versions/pgadmin4/bin/python
Installing setuptools, pip, wheel...done.
ensurepip is disabled in Debian/Ubuntu for the system python.

Python modules For the system python are usually handled by dpkg and apt-get.

    apt-get install python-<module name>

Install the python-pip package to use pip itself.  Using pip together
with the system python might have unexpected results for any system installed
module, so use it on your own risk, or make sure to only use it in virtual
environments.

Installing pip from https://bootstrap.pypa.io/get-pip.py...
curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

Virtualenv  활성화

~|⇒ pyenv activate pgadmin4 
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.

 

참고> 처음부터 설치 requirements_install.sh

sudo apt-get install python2.7-dev virtualenv python-pip libpq-dev

2. pip를 통한 설치

설치파일 다운로드 

the wheel package of pgAdmin 4 from here  .

(pgadmin4) ~|⇒ cd ~/.pyenv/versions/pgadmin4/

(pgadmin4) pgadmin4|master ⇒ wget --no-check-certificate https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl

--2017-08-29 14:16:53--  https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl
Resolving ftp.postgresql.org (ftp.postgresql.org)... 174.143.35.246, 87.238.57.227, 217.196.149.55, ...
Connecting to ftp.postgresql.org (ftp.postgresql.org)|174.143.35.246|:443... connected.
WARNING: cannot verify ftp.postgresql.org's certificate, issued by ‘O=hynix,L=Seoul,ST=Some-State,C=KR’:
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 61717154 (59M) [application/octet-stream]
Saving to: ‘pgadmin4-1.6-py2.py3-none-any.whl’

pgadmin4-1.6-py2.py3-none-any.wh 100%[=======================================================>]  58.86M   346KB/s    in 2m 52s  

2017-08-29 14:19:47 (350 KB/s) - ‘pgadmin4-1.6-py2.py3-none-any.whl’ saved [61717154/61717154]

설치 

(pgadmin4) pgadmin4|master ⇒ pip install pgadmin4-1.6-py2.py3-none-any.whl 
Processing ./pgadmin4-1.6-py2.py3-none-any.whl
....

Successfully installed Babel-2.3.4 Flask-0.11.1 Flask-Babel-0.11.1 Flask-Gravatar-0.4.2 Flask-HTMLmin-1.2 Flask-Login-0.3.2 Flask-Mail-0.9.1 Flask-Migrate-2.0.3 Flask-Principal-0.4.0 Flask-SQLAlchemy-2.1 Flask-Script-2.0.5 Flask-Security-1.7.5 Flask-WTF-0.12 Jinja2-2.7.3 Mako-1.0.7 MarkupSafe-0.23 SQLAlchemy-1.0.14 WTForms-2.0.2 Werkzeug-0.9.6 alembic-0.9.5 backports.csv-1.0.5 beautifulsoup4-4.4.1 blinker-1.3 click-6.6 extras-0.0.3 fixtures-2.0.0 html5lib-1.0b3 htmlmin-0.1.10 importlib-1.0.4 itsdangerous-0.24 linecache2-1.0.0 passlib-1.6.2 pbr-1.9.1 pgadmin4-1.6 psycopg2-2.7.3.1 pycrypto-2.6.1 pyrsistent-0.11.13 python-dateutil-2.5.0 python-editor-1.0.3 python-mimeparse-1.5.1 pytz-2014.10 simplejson-3.6.5 six-1.10.0 speaklater-1.3 sqlparse-0.1.19 testtools-2.3.0 traceback2-1.4.0 unittest2-1.1.0

Config 설정

(pgadmin4) pgadmin4|master ⇒ cd ~/.pyenv/versions/pgadmin4/local/lib/python2.7/site-packages/pgadmin4
(pgadmin4) pgadmin4|master ⇒ cp ./config.py ./config_local.py
(pgadmin4) pgadmin4|master ⇒ sudo subl config.py

pgadmin 시작

(pgadmin4) pgadmin4|master ⇒ python pgAdmin4.py
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: [email protected]
Password: 
Retype password:
pgAdmin 4 - Application Initialisation
======================================
Starting pgAdmin 4. Please navigate to http://127.0.0.1:5050 in your browser.

 브라우저에서 http://127.0.0.1:5050 

3. 런처 만들기 

icon 다운로드

(pgadmin4) pgadmin4|master ⇒ wget --no-check-certificate http://kiahosseini.github.io/assets/image/pgadmin4_install/pgadmin.svg

shell 만들기

touch pgAdmin4.sh pgAdmin4.desktop
chmod +x pgAdmin4.sh pgAdmin4.desktop

pgAdmin4.sh

(pgadmin4) pgadmin4|master ⇒ sudo subl pgAdmin4.sh
#! /bin/zsh
pyenv activate pgadmin4
python ~/.pyenv/versions/pgadmin4/local/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py &
sleep 6; sensible-browser http://127.0.0.1:5050/

 pgAdmin4.desktop  

(pgadmin4) pgadmin4|master ⇒ sudo subl pgAdmin4.desktop
[Desktop Entry]
Name=pgAdmin 4
Exec=~/.pyenv/versions/pgadmin4/local/lib/python2.7/site-packages/pgadmin4/pgAdmin4.sh
Icon=~/.pyenv/versions/pgadmin4/local/lib/python2.7/site-packages/pgadmin4/pgadmin.svg
Type=Application
Categories=Database;
Terminal=false

Link 만들기 (런처 자동로드)

pgAdmin4.desktop  => ~/share/applications/

ln -s ~/.pyenv/versions/pgadmin4/local/lib/python2.7/site-packages/pgadmin4/pgAdmin4.desktop ~/.local/share/applications/

 

Categories: Postgresql

onesixx

Blog Owner

Leave a Reply

Your email address will not be published.