LoginSignup
1
1

More than 1 year has passed since last update.

Ubuntu20.04LTS(WSL2)にPostgreSQLをインストールする

Last updated at Posted at 2021-09-03

[初投稿]
Ubuntu20.04(WSL2)上にPostgreSQL13をインストールしたので備忘録。

WSL2にアップデートした状態で、
https://www.postgresql.org/download/linux/ubuntu/

# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

# Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

# Update the package lists:
sudo apt-get update

# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql

をコメントアウトされてない部分を上から順に実行します。
次に
sudo -u postgres psql
を入力して、
postgres=#
↑の状態にコマンドラインが切り替わったらPostgreSQLのユーザー作成をします。

create role username with createdb login password 'password';
username,passwordは任意です。passwordを括っているシングルクォートも忘れずに。また、メモ帳などに記録を忘れないようにしましょう、Ruby on rails でも何でも、DBの設定で使います。
完了したらpostgres=# \duと入力してユーザー登録できているか確認しましょう。

ひとまず、PostgreSQLの立ち上げ方法だけ記録です。Ruby on rails で使う場合の記録なども随時投稿し、修正も適宜していきます。

1
1
1

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
1