まずはディレクトリを作成
mkdir ~/database
cd database
データベースクラスタを作成(データベースの格納領域のこと。ここにデータベースを作成する)
initdb -D example -U postgres
example以下のpostgresql.conf
のportを5433に変更し、コメントアウトを解除する
※このまま起動しても何故か5432が使用されているというエラーがでるため
postgres -D example
でDBを起動する
testという名前のデータベースを作成する
createdb -U postgres -p 5433 test
ターミナルを別に起動し、
psql- p 5433 -U postgres test
でデータベースに接続できる
postgresは管理ユーザなので新たにユーザを作成する
createuser -p 5433 -U postgress
で色々聞かれるので最初にユーザ名を入れ、あとはnoで
ユーザ名はとりあえずuser1で。
作成されているか確認するためデータベースに接続
psql -p 5433 -U user1 test
で¥duと入力すればデータベースユーザが作成されているのがわかる
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
user1 | | {}
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
user1 | | {}
次はsailsからアクセスするようにします。
0 件のコメント:
コメントを投稿