国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

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)

5 Best Open Source Mathematical Equation Editors for Linux 5 Best Open Source Mathematical Equation Editors for Linux Jun 18, 2025 am 09:28 AM

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

SCP Linux Command – Securely Transfer Files in Linux SCP Linux Command – Securely Transfer Files in Linux Jun 20, 2025 am 09:16 AM

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

Gogo - Create Shortcuts to Directory Paths in Linux Gogo - Create Shortcuts to Directory Paths in Linux Jun 19, 2025 am 10:41 AM

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

What is a PPA and how do I add one to Ubuntu? What is a PPA and how do I add one to Ubuntu? Jun 18, 2025 am 12:21 AM

PPA is an important tool for Ubuntu users to expand their software sources. 1. When searching for PPA, you should visit Launchpad.net, confirm the official PPA in the project official website or document, and read the description and user comments to ensure its security and maintenance status; 2. Add PPA to use the terminal command sudoadd-apt-repositoryppa:/, and then run sudoaptupdate to update the package list; 3. Manage PPAs to view the added list through the grep command, use the --remove parameter to remove or manually delete the .list file to avoid problems caused by incompatibility or stopping updates; 4. Use PPA to weigh the necessity and prioritize the situations that the official does not provide or require a new version of the software.

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

How to create a file of a specific size for testing? How to create a file of a specific size for testing? Jun 17, 2025 am 09:23 AM

How to quickly generate test files of a specified size? It can be achieved using command line tools or graphical software. On Windows, you can use fsutilfilecreatenew file name size to generate a file with a specified byte; macOS/Linux can use ddif=/dev/zeroof=filebs=1Mcount=100 to generate real data files, or use truncate-s100M files to quickly create sparse files. If you are not familiar with the command line, you can choose FSUtilGUI, DummyFileGenerator and other tool software. Notes include: pay attention to file system limitations (such as FAT32 file size upper limit), avoid overwriting existing files, and some programs may

NVM - Install and Manage Multiple Node.js Versions in Linux NVM - Install and Manage Multiple Node.js Versions in Linux Jun 19, 2025 am 09:09 AM

Node Version Manager (NVM) is a simple bash script that helps manage multiple Node.js versions on your Linux system. It enables you to install various Node.js versions, view available versions for installation, and check already installed versions.NV

How to install Linux alongside Windows (dual boot)? How to install Linux alongside Windows (dual boot)? Jun 18, 2025 am 12:19 AM

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

See all articles