〇PostgreSQL12(OS標準)とtestデータベース・testユーザを作成する方法
以下のコマンドを実行します。
sudo localedef -i ja_JP -c -f UTF-8 -A /usr/share/locale/locale.alias ja_JP.UTF-8
  ※ locale -aでja_JP.UTF-8が表示されれば実行する必要なし
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 localhost -U test -W test〇関連情報
・PostgreSQLに関する他の情報はこちらを参照してください。
 
0 件のコメント:
コメントを投稿