LoginSignup
0
0

More than 1 year has passed since last update.

WindowsへのPostgreSQLのインストール手順

Last updated at Posted at 2022-06-17
../

Windows環境にPostgreSQL14.2をインストールしてみた。その手順を残しておく。

(1) PostgreSQLをダウンロードする。
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
・Windows x86-64の「14.2」をダウンロードする。

(2) postgresql-14.2-2-windows-x64.exeを実行してインストールする。
・serverとcommand line toolsを選択する。(※pgAdmin4:GUIツール、stackBuilder:関連ツールは不要)
・パスワード「xxx」を設定する。
・Lacaleを「Japanese」にする。
※サービス「postgresql-x64-14」が起動されていることを確認しておこう。

(3) 環境変数Pathに以下を追加する。
C:\Program Files\PostgreSQL\14\bin

(4) postgresqlの設定を行う。
① C:\Program Files\PostgreSQL\14\data\postgresql.confを開き、修正する。

listen_addresses = '*'
↓	
listen_addresses = 'localhost'

② C:\Program Files\PostgreSQL\14\data\pg_hba.confを開き、修正する。

# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
↓
host    all             all             127.0.0.1/32            password

③ サービス「postgresql-x64-14」を再起動する。

(5) cmdからCLIで試してみる。

> psql -V
> psql -U postgres  			// CLIの開始
# create database seminar;		// DBの作成
# \l							// DB一覧の表示
# \c seminar					// DBへの接続
# create table dummy (id int,name varchar(20));
# \dn
# insert into dummy values (10,'abc'),(20,'あいう');
# update dummy set name='ABC' where id=10;
# select * from dummy;
# \d							// テーブル一覧
# \q							// CLIの終了	
../
0
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
0
0