PGAdmin4 is a popular open-source and web-based administration and management tool for PostgreSQL databases. It provides a powerful graphical interface that simplifies the creation, maintenance, and use of database objects. It also includes a full-featured SQL editor that helps in writing SQL scripts and executing them.
15 min
Edited:29-09-2024
The importance of PGAdmin4 lies in its comprehensive set of features and tools that aid in managing PostgreSQL databases. These include:
A user-friendly interface for managing and manipulating databases, Tools for creating, altering, and dropping database objects, An SQL editor for executing SQL queries, scripts, and commands. A dashboard that provides insights into the health and performance of databases.
The PGAdmin4 Docker extension allows you to use this powerful tool directly from Docker Desktop, making it even easier to manage your PostgreSQL databases in a Docker environment
If you are using Docker Desktop v4.10.1 or less you can install the extension by running the command (CLI required):
1. $ docker extension install mochoa/pgadmin4-docker-extension:8.12.0
After installing the extension, a new entry will appear in the Extensions (Beta) pane of Docker Desktop. Clicking on the pgAdmin 4 icon will open the main window, displaying the pgAdmin site once it has fully loaded. During the initial login, you will be prompted to enter a master password for pgAdmin. Enter your master password and click "OK" to proceed.
By selecting "Add New Server," you can connect to a PostgreSQL server running on Docker Desktop or externally. The IP address for the PostgreSQL instance running on Docker Desktop can be found in the menu under Settings -> Resources -> Network -> Docker subnet.
Adding a new server, on the connection tab, you will need to add the following details:
1. Name: Test
2. Hostname/address:
3. Port:
4. Maintenance database:
5. Username:
6. Password:
Just run the following command to uninstall pgadmin4
1. $ docker extension uninstall mochoa/pgadmin4-docker-extension:8.12.0
After installing pgAdmin 4, launch the application. You will be prompted to enter your master password. Once logged in, you will see the pgAdmin dashboard.
In the left sidebar, right-click on "Servers" and select Create > Server.
In the Create - Server window, enter a name for your server (e.g., "Local PostgreSQL").
Go to the Connection tab
1 - Enter localhost or the appropriate IP address in the Host field (e.g., 192.168.65.2 for Docker).
2 - Use the default port 5432.
3 - Enter your PostgreSQL username and password.
Click Save to connect to your server.
1- In the left sidebar, right-click on your server name and select Create > Database.
2- In the Create - Database window:
Enter a name for your database (e.g., "SampleDB").
Click Save to create the database.
4- Create a New Table
1 - Expand the Databases section in the left sidebar and select your newly created database (SampleDB).
2 - Right-click on Schemas, then navigate to public and select Tables. Click Create > Table.
3 - In the Create - Table window: Enter a name for your table (e.g., "Employees").
4 - Go to the Columns tab and click on the + icon to add columns, For example, add: Name (Data type: VARCHAR, Length: 100). Age (Data type: INTEGER). Position (Data type: VARCHAR, Length: 50)
After adding the desired columns, click Save to create the table.
5- Insert Data into the Table
Right-click on the Employees table and select Query Tool. In the Query Editor, enter the following SQL command to insert data:
1. INSERT INTO Employees (Name, Age, Position) VALUES
2. ('Alice Johnson', 30, 'Software Engineer'),
3. ('Bob Smith', 25, 'Data Analyst');
Click the Execute/Refresh button (lightning bolt icon) to run the query. You should see a success message indicating that the data has been inserted.
6- Query the Data
In the same Query Tool, enter the following SQL command to retrieve the data:
1. SELECT * FROM Employees;
Click Execute/Refresh again to see the list of employees you just added.
pgAdmin 4 provides an intuitive interface for managing PostgreSQL databases, making tasks like creating databases and tables straightforward. By following this example, you’ve learned how to connect to a server, create a database, define a table, and insert and query data. With these foundational skills, you can further explore the features of pgAdmin 4 to manage your PostgreSQL databases effectively.
14-10-2024
This article offers a detailed guide on installing and configuring IPTables on an Ubuntu VPS. IPTables is a powerful firewall tool that helps secure your server by controlling inbound and outbound traffic. Learn how to set up rules for traffic filtering, configure basic security policies, and apply custom rules to protect your VPS.
IPtables
security
12 min
This article offers a comprehensive guide on installing and configuring ModSecurity, a powerful web application firewall (WAF), on an Ubuntu VPS. Learn how to secure your server by filtering and monitoring HTTP requests, set up ModSecurity with Nginx or Apache, and apply rules to protect against common web attacks.
Modsecurity
security
10 min
14-10-2024
This article provides a comprehensive guide on installing and configuring PHP-FPM (FastCGI Process Manager) on an Ubuntu VPS. Learn how to optimize PHP performance for your web applications by configuring PHP-FPM with Nginx or Apache, managing pools, and fine-tuning settings for efficient processing of PHP scripts.
PHP-FPM
speed
optimise
12 min