1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ArchLinux PostgreSqlを入れてみた

Last updated at Posted at 2021-06-06

概要

ArchLinuxでのPostgreSqlの構築について紹介します。
PostgreSqlは、Arch Linuxの公式パッケージリポジトリで入手でるため、非常に簡単にインストールできます。

PostgreSqlbのインストール

まず、pacmanパッケージマネージャーのパッケージデータベースを更新します。

sudo pacman -Sy

次のコマンドを実行し、ArchLinuxにPostgreSQLインストールします。

sudo pacman -S postgresql

バージョンの確認

postgres --version

実行ステータスの確認

sudo systemctl status postgresql

PostgreSQLを起動するためにはPostgreSQLのデータディレクトリを初期化させる必要があります。
また、PostgreSQLのデータディレクトリを初期化する前に、次のコマンドを使用してpostgresユーザーとしてログインする必要があります。
※PostgreSQLを使用または管理するには、常にpostgresユーザーとしてログインする必要があります。
そうではない場合、権限エラーが発生し、機能しない可能性があります。

sudo su - postgres

次のコマンドでPostgreSQLのデータディレクトリを初期化し、データディレクトリが生成されます。
※ Arch Linux上のPostgreSQLのデフォルトのデータディレクトリは/ var / lib / postgres / dataです。

initdb --locale en_US.UTF-8 -D /var/lib/postgres/data

postgresユーザーからログアウトします。

exit

PostgreSQLのデータディレクトリが生成されたので、次のコマンドでPostgreSQLを起動できます。

sudo systemctl START postgresql

次のコマンドでPostgreSQLが再度実行されているかどうかを確認できます。

sudo systemctl STATUS postgresql

システムの起動時にPostgreSQLを追加して、システムの起動時に自動的に起動するようにするには次のコマンドを実行し、PostgreSQLをシステムの起動に追加します。

sudo systemctl enable postgresql

以上でArchにPostgreSqlを簡単にインストールし、また、システム起動にPostgreSqlを自動的に起動させることができます。
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?