〇PostgreSQL12とtestデータベース・testユーザを作成する方法
以下のコマンドを実行します。
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get -y install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-12
echo "listen_addresses='*'" | sudo tee -a /etc/postgresql/12/main/postgresql.conf
echo "host all all 127.0.0.1/32 password" | sudo tee -a /etc/postgresql/12/main/pg_hba.conf
echo "host all all 192.168.1.0/24 password" | sudo tee -a /etc/postgresql/12/main/pg_hba.conf
sudo systemctl restart postgresql.service
sudo su - postgres << EOF
psql -c "
alter user postgres with password 'postgres';
create user test with password 'test';
"
psql -c "
create database test owner test encoding 'UTF8' lc_collate 'ja_JP.UTF-8' lc_ctype 'ja_JP.UTF-8' template 'template0';
"
EOF
psql -h 127.0.0.1 -U test -W -d test << EOF
select version();
EOF
0 件のコメント:
コメントを投稿