Install pgAdmin 4 for PostgreSQL on FreeBSD 12.2
source link: https://www.vultr.com/docs/install-pgadmin-4-for-postgresql-on-freebsd-12-2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Using a Different System?
Introduction
pgAdmin is an open-source software project for administrating and managing PostgreSQL database server that includes a graphical administration interface, an SQL query tool, and a procedural code debugger. This guide explains how to install pgAdmin 4 on FreeBSD 12.2.
Prerequisites
- Deploy a Vultr FreeBSD 12.2 Server.
- Create non-root sudo user.
- Install PostgreSQL 12.
1. Configure PostgreSQL
Access the PostgreSQL instance.
$ sudo su - postgres
Modify the default user
postgres
password.psql -c "alter user postgres with password 'yourPassword'"
Create user
pgadmin
.createuser pgadmin
Create a
testdb
database owned by userpgadmin
.createdb testdb -O pgadmin
Exit the PostgreSQL instance
exit
2. Install pgAdmin 4
Create a symbolic link of
Python3.8
binary to/usr/local/bin/python
.$ sudo ln -s /usr/local/bin/python3.8 /usr/local/bin/python
Install and upgrade
pip
, which is a package manager for Python.$ sudo pkg install py38-pip $ sudo pip install --upgrade pip
Install the
virtualenv
package, which is used to create isolated Python environments.$ sudo pkg install py38-virtualenv
Create a virtual environment for
pgAdmin
.$ virtualenv pgadmin4
Activate the Virtual environment.
$ . pgadmin4/bin/activate
Install Python dependencies.
$ sudo pip install cryptography==3.1.1 pyopenssl ndg-httpsclient pyasn1 simple-websocket
Install Python SQLite3 package.
$ sudo pkg install py38-sqlite3
Download and install Python wheel package for pgAdmin. To get the latest version, go to pgAdmin wheel packages.
$ sudo pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v5.4/pip/pgadmin4-5.4-py3-none-any.whl
Create the data directories and give write permissions.
$ sudo mkdir -pv /var/lib/pgadmin $ sudo chmod 770 /var/lib/pgadmin $ sudo mkdir -pv /var/log/pgadmin $ sudo chmod 770 /var/log/pgadmin
Install the nano editor.
$ sudo pkg install nano
Copy the pgAdmin configuration file.
$ sudo cp ./pgadmin4/lib/python3.8/site-packages/pgadmin4/config.py ./pgadmin4/lib/python3.8/site-packages/pgadmin4/config_local.py
Edit the configuration file.
$ sudo nano ./pgadmin4/lib/python3.8/site-packages/pgadmin4/config_local.py
Find the line
DEFAULT_SERVER = '127.0.0.1'
and change it to match the line below.DEFAULT_SERVER = '0.0.0.0'
Save and exit the file.
Run pgAdmin 4.
$ sudo python pgadmin4/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py
Enter your email address and password to create your pgAdmin administrator account.
Open your browser and navigate to your server's IP address at port 5050 to access the pgAdmin 4 user interface. Use the email address and password that you set in the previous step. For example:
http://192.0.2.11:5050
3. Connect to the Database Server with pgAdmin 4
Go to the pgAdmin 4 web portal and click Add New Server.
You'll be prompted with a dialog box. Enter your preferred server name in the Name field.
Switch to the Connection tab and enter the required fields with the appropriate data.
- Enter localhost under the Host name/address.
- Leave Port value as 5432.
- Enter
testdb
under Maintenance database. - Enter
pgadmin
under Username. - Enter the database password you chose in section 1.
- Click Save to login to the server.
After a successful connection, choose your server in the upper left corner, then expand the arrows to access the testdb database.
Conclusion
You have installed pgAdmin 4 for PostgreSQL Server. You can now manage your database server via the dashboard.
Want to contribute?
You could earn up to $600 by adding new articles
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK