0
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 5 years have passed since last update.

Railsのデータベースをポスグレに指定して、プロジェクトを立ち上げる方法

Last updated at Posted at 2019-12-30

①ポスグレのインストール

$ brew update
$ brew install postgresql

②ポスグレを起動するとエラーがでる

$ postgresql
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.

③エラーの解消
コンフィグファイルの設定をして下さいと書いている。
ホームディレクトリに戻る

$ cd ~

ホームディレクトリに設定用のファイル".bash_profile"、".bashrc"があるか下記コマンドで確認

$ ls -a

ない場合は、下記コマンドで作る

$ touch ~/.bash_profile
$ touch ~/.bashrc

再度確認すると、ある。

$ ls -a

.bash_profileと、.bashrcの説明は下記URLを参照
https://qiita.com/takutoki/items/021b804b9957fe65e093

先ほど作った、~/.bash_profileに環境変数を設定してパスを通す

④下記コマンドで、ターミナルをコマンドモードに切り替る

$ vi .bash_profile

⑤コマンドモードに入ったらiを押してインサートに切り替える

i

⑥下記、環境変数を追記する

export PGDATA='/usr/local/var/postgres'

⑦保存してコマンドモードを終了する

キーボード【ESC】

下記コマンドを入力

:wq

⑧下記コマンドを入力して変更を反映させる

$ source .bash_profile

⑨下記コマンドにて、postgresqlが立ち上げれば設定完了

$ postgres

⑩データベースをポスグレに指定し、好きなバージョンも指定し、Railsプロジェクトを作成して終了

$ rails _5.1.7_ new アプリ名 -d postgresql
0
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
0
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?