4. Install pgAdmin 4 on CentOS 8 system

pgAdmin 4 is an open source database management tool designed to manage and operate PostgreSQL database systems. It provides a graphical user interface (GUI) that enables users to easily connect to a PostgreSQL database instance, execute SQL queries, manage database objects, back up and restore data, and monitor database performance.

  1. Cross-platform: pgAdmin 4 is a cross-platform tool, supporting Windows, macOS and various Linux distributions, so it can run on different operating systems.

  2. Graphical User Interface: pgAdmin 4 provides an intuitive graphical user interface that enables users to easily manage PostgreSQL databases without requiring in-depth knowledge of command line tools. This makes database management more friendly and visual.

  3. Multiple connection support: You can connect to multiple PostgreSQL database instances simultaneously, which is useful for managing multiple databases or servers. Each connection can be configured to access a different database, or even connect to a different version of PostgreSQL.

  4. SQL query tool: pgAdmin 4 provides a powerful SQL query tool that allows you to write and execute SQL queries. You can also save and load queries for reuse later.

  5. Database object management: You can use pgAdmin 4 to create, modify, and delete database objects, such as tables, views, indexes, functions, schemas, etc. It also provides a tree view for quick navigation and management of database objects.

  6. Backup and Restore: pgAdmin 4 allows you to create database backups, as well as restore backups that have been created. This is a critical function for database maintenance and disaster recovery.

  7. Data Import and Export: You can use pgAdmin 4 to import and export data to a PostgreSQL database from different data sources, or to export data to other formats, such as CSV or Excel.

  8. Graphical visualization tools: pgAdmin 4 provides several visualization tools to help you understand database performance and structure. This includes query plan visualization, performance monitor, and table space management.

  9. Extensibility: pgAdmin 4 supports extended functions through plug-ins. Different plug-ins can be installed and enabled as needed to meet specific database management needs.

  10. Security: pgAdmin 4 provides a variety of security features, including password protection, SSL connection support and permission management, to ensure database security.

  11. Active community support: pgAdmin 4 is an open source project with active community support and ongoing development, so you can expect constant improvements and updates.

pgAdmin 4 is suitable for the management and maintenance of PostgreSQL databases. It makes database management easier, especially for users who are less familiar with the command line.

Insert image description here
pgAdmin 4 provides rich functionality to facilitate the management and operation of PostgreSQL databases. Its main functions are:

  1. Database connection management: pgAdmin 4 allows you to connect to multiple PostgreSQL database instances, manage those connections, and easily switch connections between them.

  2. SQL Query Tool: Provides a powerful SQL query tool that can write, edit and execute SQL queries to retrieve and modify data in the database.

  3. Database Object Management: Allows you to create, modify and delete database objects, such as tables, views, indexes, functions, schemas, etc.

  4. Data import and export: Supports importing data from different formats (such as CSV, Excel) into the database, and exporting data to other formats.

  5. Backup and Restore: You can create a backup of your database and restore it if needed. This is very important for database backup and disaster recovery.

  6. Table space management: A tool for managing database table spaces, which can organize and manage the storage of database objects more effectively.

  7. Query Tools: Provides query plan visualization, performance monitor, and execution plan analysis to help optimize query performance.

  8. Visualization tools: Allows you to visually view and understand the database structure, including tables, views, relationships, foreign keys, etc.

  9. Extensibility: Supports plug-in system, various plug-ins can be installed and enabled to extend the functionality of the tool.

  10. Security: Provides password protection, SSL connection support and permission management to ensure database security.

  11. Multi-language support: pgAdmin 4 supports multiple languages ​​to meet the needs of different users.

  12. SQL Editor: SQL editor with syntax highlighting, code auto-completion and error checking, making it easier to write SQL queries.

  13. Server Status Monitoring: Allows monitoring of database server performance and status, including connections, queries, and resource usage.

  14. Scheduled tasks: You can create and manage scheduled tasks to perform database maintenance, data cleaning, and other automated tasks.

  15. Version Control: Supports version control tools such as Git to facilitate collaboration and tracking changes to the database schema.

pgAdmin 4 provides a wide range of features that make managing and operating PostgreSQL databases easier and more efficient. These capabilities cover all aspects of database management, from basic querying and object management to advanced performance monitoring and security. This makes it a powerful tool for PostgreSQL database administrators and developers.

pgAdmin 4 is a cross-platform database management tool that supports multiple operating systems and platforms.

  1. Windows: pgAdmin 4 supports Windows operating systems, including Windows 7, 8, Windows 10, 11, and Windows Server series server versions.

  2. macOS: pgAdmin 4 can also run on macOS, providing integration with macOS systems.

  3. Linux: pgAdmin 4 can run on various Linux distributions, including but not limited to Ubuntu, Debian, Fedora, CentOS, Red Hat Enterprise Linux (RHEL), etc.

  4. Docker: pgAdmin 4 also provides a Docker container version, allowing you to run it on any platform that supports Docker.

pgAdmin4 is a web application developed in python. It can be deployed in web mode to be accessed through a browser, or in desktop mode to run independently.

Official download address: https://www.pgadmin.org/download/

Insert image description here
Last time we have installed the PostgreSQL 15.4 database server on the CentOS 8 system, which is a prerequisite for installing pgAdmin 4.

Today we will try to continue installing pgAdmin 4 on CentOS 8 system.

Installing pgAdmin 4 on CentOS 8 can be done through the package manager and virtual environment.

In actual production environments, installing pgAdmin 4 in a virtual environment is a common way because it has the following advantages:

  1. Isolation: The virtual environment installs pgAdmin 4 in an isolated environment without affecting system-wide Python packages. This means you can install different versions of pgAdmin 4 in different virtual environments without conflicts.

  2. Version Management: Using a virtual environment, you can easily manage different versions of pgAdmin 4. This is useful for developing and testing different versions of an application or using different versions of pgAdmin 4 in different projects.

  3. Dependency Management: Virtual environments allow you to define and manage dependencies within a specific environment. This helps ensure that the dependencies required by pgAdmin 4 do not conflict with other parts of the application.

  4. Easy upgrades and rollbacks: Virtual environments can be easily upgraded or rolled back to a specific version without impacting other parts of the system. This is useful when testing new releases, fixing issues, or rolling back to a previous stable release.

  5. Flexibility: Virtual environments provide greater flexibility to customize installation and configuration to meet specific project or user needs.

  6. Security: Virtual environments can improve security by restricting access to system-wide Python packages. It reduces the risk of potential dependency conflicts and vulnerabilities.

  7. No root privileges required: Installing pgAdmin 4 in a virtual environment typically does not require root privileges, which increases security and reduces risk.

Although installing pgAdmin 4 using a virtual environment is more complex in some cases, it is generally a more recommended method, especially in development and test environments.

But in a production environment, we can also use a web server to serve pgAdmin 4 for access via a web browser instead of installing it in a local virtual environment.

This can better meet the security and maintainability needs of production environments.

Next we choose the commonly used method and use a virtual environment to install pgAdmin 4:

  1. Install dependencies: First, make sure your CentOS 8 system has installed some necessary dependencies, such as Python and some development tools. You can install these dependencies using the following command:

    sudo dnf install python3 python3-pip python3-devel gcc make
    

Insert image description here

  1. Install virtual environment tools: Install Python's virtual environment tools to create an independent environment for pgAdmin 4:

    sudo pip3 install virtualenv
    

Insert image description here

  1. Create virtual environment : Create a new virtual environment in which you can install pgAdmin 4:

    mkdir ~/pgadmin4
    cd ~/pgadmin4
    
    virtualenv venv
    

Insert image description here

  1. Activate virtual environment: Activate a virtual environment to ensure that installed packages do not affect system-wide Python packages:

    source venv/bin/activate
    

Insert image description here

  1. Download and install pgAdmin 4: Use pip to install pgAdmin 4. You can choose between a stable version or a development version:

    • Install stable version:

      pip install pgadmin4
      
    • Install the development version:

      pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/snapshots/pgadmin4-latest.tar.gz
      

Insert image description here
Insert image description here

  1. Configure pgAdmin 4: In the virtual environment, run the following command to generate the configuration file for pgAdmin 4:
  /root/pgadmin4/venv/bin/python venv/lib/python3.6/site-packages/pgadmin4/setup.py

NOTE: Make sure to replace "3.x" in the above command with the actual Python version you are using.
Insert image description here

  1. Start pgAdmin 4: Start the pgAdmin 4 web server using the following command:
/root/pgadmin4/venv/bin/python venv/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

Make sure to replace "3.x" with your Python version.
Insert image description here

  1. Visit pgAdmin 4: Visit http://localhost:5050 in the browser, we will see the login interface of pgAdmin 4. By default, the username is "[email protected]" and the password is "pgadmin" as we configured it. You can change your password after logging in for the first time.

Insert image description here
After logging in, as shown in the figure:

Insert image description here
You can also select Simplified Chinese on the login interface

Insert image description here

In this way, we successfully installed and ran pgAdmin 4 on CentOS 8. Please note that if we plan to use pgAdmin 4 in a production environment, there are some additional configuration and security considerations that need to be made to ensure system stability and security.

おすすめ

転載: blog.csdn.net/GYN_enyaer/article/details/133763271