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 1 year has passed since last update.

wsl2のUbuntu20.4へのpostgresの導入方法

Last updated at Posted at 2021-04-24

コマンド一覧

sudo apt update
sudo apt install postgresql postgresql-contrib

# postgres起動
sudo /etc/init.d/postgresql start

# postgresユーザで接続
sudo -i -u postgres

# postgresに入れるか検証(はいれたら\qで終了)
psql

# postgresにuser追加し、権限とか聞かれるので確認
createuser --interactive

#psql内に入り、作成したパスワード変更 passwordはdetabase.ymlのdevelopmentに記載されているやつ
psql
alter role username with password 'password'

# user名でDB作成
createdb username

# psqlでユーザ経由で入れるか確認(パスワード入れる)
psql -U username

# developmentのDB作成
createdb development_database -O username
 
# 認証の変更
sudo vi /etc/postgresql/12/main/pg_hba.conf

## 変更前
local all postgres peer
## 変更後
local all postgres md5

途中つまったら、適宜postgresqlを再起動させてください。
sudo /etc/init.d/postgresql restart

参考資料

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-20-04-ja
https://ryotatake.hatenablog.com/entry/2019/05/03/postgresql_peer_authentication_failed

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?