亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Prerequisites
Install Prerequisites on Linux
Download the PostgreSQL Source Code
Configure PostgreSQL from Source
Install PostgreSQL from Source
Create Postgres User
Initialize Postgres Database
Start PostgreSQL Service
Connect to PostgreSQL
Home System Tutorial LINUX How to Install PostgreSQL Using Source Code in Linux

How to Install PostgreSQL Using Source Code in Linux

Jun 03, 2025 am 09:56 AM

How to Install PostgreSQL Using Source Code in Linux

PostgreSQL, an open-source relational database management system, is highly valued for its powerful features and adaptability. Although many Linux distributions offer PostgreSQL via their package managers, building it from source gives users more personalization and control.

This article will guide you through the process of installing PostgreSQL 16 using source code on Linux systems.

For those preferring a simpler installation method via the package manager, refer to the following guides:

  • How to Install PostgreSQL 16 on RHEL-Based Systems
  • How to Install PostgreSQL 16 and pgAdmin on Debian 12

Prerequisites

Before proceeding with the PostgreSQL installation, confirm that your system satisfies the following prerequisites:

  • A Linux distribution (this guide uses Debian for illustration).
  • A Linux system with a non-root user possessing sudo privileges.
  • Essential development tools like GCC and Make must be installed.
  1. Install Prerequisites on Linux

Initially, install necessary development tools such as GCC and Make using the distribution's package manager as indicated.

On RHEL-based distributions like CentOS, Fedora, Rocky Linux, and Alma Linux:

<code>sudo yum groupinstall development-tools
sudo yum install zlib-devel readline-devel libicu-devel</code>

On Debian-based distributions such as Ubuntu and Linux Mint:

<code>sudo apt install gcc build-essential zlib1g-dev libreadline6-dev libicu-dev pkg-config</code>
  1. Download the PostgreSQL Source Code

With the prerequisites in place, download the source code tar file from the official PostgreSQL website using the following wget command directly on the system. At the time of writing, the latest version is PostgreSQL 16.1.

<code>wget https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.bz2</code>

Next, use the tar command to extract the downloaded tarball file. A new directory named postgresql-16.1 will be created.

<code>tar -xvf postgresql-16.1.tar.bz2
cd postgresql-16.1/
ls -l</code>

Sample Output:

<code>-rw-r--r--.  1 tecmint tecmint    365 Nov  7 03:34 aclocal.m4
drwxr-xr-x.  2 tecmint tecmint   4096 Nov  7 03:47 config
-rwxr-xr-x.  1 tecmint tecmint 584560 Nov  7 03:34 configure
-rw-r--r--.  1 tecmint tecmint  87292 Nov  7 03:34 configure.ac
drwxr-xr-x. 61 tecmint tecmint   4096 Nov  7 03:47 contrib
-rw-r--r--.  1 tecmint tecmint   1192 Nov  7 03:34 COPYRIGHT
drwxr-xr-x.  3 tecmint tecmint   4096 Nov  7 03:47 doc
-rw-r--r--.  1 tecmint tecmint   4288 Nov  7 03:34 GNUmakefile.in
-rw-r--r--.  1 tecmint tecmint    277 Nov  7 03:34 HISTORY
-rw-r--r--.  1 tecmint tecmint  64601 Nov  7 03:48 INSTALL
-rw-r--r--.  1 tecmint tecmint   1875 Nov  7 03:34 Makefile
-rw-r--r--.  1 tecmint tecmint 102017 Nov  7 03:47 meson.build
-rw-r--r--.  1 tecmint tecmint   6266 Nov  7 03:34 meson_options.txt
-rw-r--r--.  1 tecmint tecmint   1213 Nov  7 03:34 README
drwxr-xr-x. 16 tecmint tecmint   4096 Nov  7 03:48 src</code>
  1. Configure PostgreSQL from Source

Since postgres is an open-source database, it can be compiled from source code based on individual needs. You can customize the build and installation process by providing one or more command-line options for various optional features.

Use the following command for help regarding available options and configuration usage, as shown.

<code>./configure --help</code>

How to Install PostgreSQL Using Source Code in Linux

Now run the configure script, which will check your system for dependencies and configure the build accordingly.

<code>./configure</code>

How to Install PostgreSQL Using Source Code in Linux

  1. Install PostgreSQL from Source

Once configured, use the following commands to compile and install PostgreSQL from the source.

<code>make
sudo make install</code>

How to Install PostgreSQL Using Source Code in Linux

  1. Create Postgres User

Create a postgres user and directory to serve as the data directory for initializing the database cluster. The owner of this data directory should be the postgres user, and permissions should be set to 700. Additionally, set a path for the PostgreSQL binaries for convenience.

<code>sudo useradd postgres
sudo passwd postgres
sudo mkdir -p /pgdatabase/data
sudo chown -R postgres: /pgdatabase/data
sudo sh -c "echo 'export PATH=$PATH:/opt/PostgreSQL/bin' > /etc/profile.d/postgres.sh"
source /etc/profile.d/postgres.sh </code>
  1. Initialize Postgres Database

Now initialize the database using the following command as the postgres user before using any postgres commands.

<code>su postgres
initdb -D /pgdatabase/data/ -U postgres -W</code>

Where -D specifies the location for this database cluster or the data directory where you want to initialize the database cluster, -U specifies the database superuser name, and -W prompts for the superuser password.

How to Install PostgreSQL Using Source Code in Linux

For more information and options, refer to initdb --help.

  1. Start PostgreSQL Service

After initializing the database, start the database cluster. If you need to modify the port or specify the listening address for the server, edit the /pgdatabase/data/postgresql.conf file in the data directory of the database server.

<code>nano /pgdatabase/data/postgresql.conf</code>

How to Install PostgreSQL Using Source Code in Linux

Now, start the PostgreSQL service.

<code>pg_ctl -D /pgdatabase/data/ start</code>

How to Install PostgreSQL Using Source Code in Linux

After starting the database, verify the status of the postgres server process by using the following ps and netstat commands.

<code>ps -ef |grep -i postgres
netstat -apn |grep -i 51751</code>

How to Install PostgreSQL Using Source Code in Linux

We can see that the database cluster is running smoothly, and startup logs can be found at the location specified with the -l option while starting the database cluster.

<code>pg_ctl -D /pgdatabase/data/ -l logfile start</code>
  1. Connect to PostgreSQL

Now connect to the database cluster and create a database by using the following commands.

<code>psql -p 5432
<strong>postgres=#</strong> create database test;
<strong>postgres=#</strong> \l to list all databases in cluster
<strong>postgres=#</strong> \q to quit from postgres console</code>

How to Install PostgreSQL Using Source Code in Linux

If you prefer a graphical tool called pgAdmin to manage your PostgreSQL, follow these guides to install pgAdmin on your Linux

The above is the detailed content of How to Install PostgreSQL Using Source Code in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Jul 05, 2025 am 09:25 AM

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

7 Ways to Speed Up Firefox Browser in Linux Desktop 7 Ways to Speed Up Firefox Browser in Linux Desktop Jul 04, 2025 am 09:18 AM

Firefox browser is the default browser for most modern Linux distributions such as Ubuntu, Mint, and Fedora. Initially, its performance might be impressive, however, with the passage of time, you might notice that your browser is not as fast and resp

How to troubleshoot DNS issues on a Linux machine? How to troubleshoot DNS issues on a Linux machine? Jul 07, 2025 am 12:35 AM

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

How would you debug a server that is slow or has high memory usage? How would you debug a server that is slow or has high memory usage? Jul 06, 2025 am 12:02 AM

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

Install Guacamole for Remote Linux/Windows Access in Ubuntu Install Guacamole for Remote Linux/Windows Access in Ubuntu Jul 08, 2025 am 09:58 AM

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

How to Burn CD/DVD in Linux Using Brasero How to Burn CD/DVD in Linux Using Brasero Jul 05, 2025 am 09:26 AM

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

How to find my private and public IP address in Linux? How to find my private and public IP address in Linux? Jul 09, 2025 am 12:37 AM

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 Jul 13, 2025 am 09:09 AM

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

See all articles