--- lang: ja-jp breaks: true --- # Ubuntu に PostgreSQL をインストール 2021-03-17 > Ubuntu 20.04にPostgreSQLをインストールする方法 [クイックスタート] > https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-20-04-quickstart-ja ```shell= $ sudo apt update ``` ###### PostgreSQLをインストール ```shell= $ sudo apt install postgresql postgresql-contrib ``` ###### postgres ユーザのパスワード設定 ```shell= $ sudo passwd postgres ``` ###### postgresユーザになる ```shell= $ sudo -i -u postgres ``` ```shell= # sudo service postgresql restart # sudo systemctl enable postgresql Synchronizing state of postgresql.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable postgresql # ``` ```shell= $ sudo -u postgres psql psql (12.6 (Ubuntu 12.6-0ubuntu0.20.10.1)) Type "help" for help. postgres=# ``` ## 確認 ### psqlコマンド ```shell= $ which psql /usr/bin/psql ``` ### postgresプロセス ```shell= $ ps -aux | grep postgres | grep -v grep postgres 682 0.0 0.6 229628 29064 ? Ss 4月13 0:00 /usr/lib/postgresql/12/bin/postgres -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf postgres 717 0.0 0.1 229752 6300 ? Ss 4月13 0:00 postgres: 12/main: checkpointer postgres 718 0.0 0.1 229768 6044 ? Ss 4月13 0:00 postgres: 12/main: background writer postgres 719 0.0 0.2 229628 10108 ? Ss 4月13 0:00 postgres: 12/main: walwriter postgres 721 0.0 0.1 230324 8560 ? Ss 4月13 0:00 postgres: 12/main: autovacuum launcher postgres 722 0.0 0.1 84124 4788 ? Ss 4月13 0:00 postgres: 12/main: stats collector postgres 723 0.0 0.1 230188 6968 ? Ss 4月13 0:00 postgres: 12/main: logical replication launcher ``` ## 外部からの接続を許可 [外部からの接続を許可](https://hackmd.io/ngi85ec3R2Ou6idutQ65tQ) <iframe src="https://hackmd.io/ngi85ec3R2Ou6idutQ65tQ" width="100%" height="500"> </iframe> ###### tags: `Ubuntu` `PostgreSQL`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up