質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Q&A

解決済

2回答

2833閲覧

MacのOS X EI Captionにてpostgresqlが動きません

tammax

総合スコア7

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

0グッド

0クリップ

投稿2016/01/23 18:28

編集2016/01/24 14:45

現在下記の環境で作業をしております。

OS: OS X EI Caption
バージョン: 10.11.3

postgresqlの9.3が必要なため、下記のコマンドを実行しました。

brew install homebrew/versions/postgresql93
ln -sfv /usr/local/opt/postgresql93/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql93.plist
sudo chown -R ユーザー名 /usr/local/var/postgres

下記コマンド実行すると
postgres --version
ポスグレのバージョンが表示されるため、インストールは成功しています。
postgres (PostgreSQL) 9.3.9

しかし実際下記のコマンドを実行しようとすると
createuser -s -P postgres

下記のエラーが発生します。
createuser: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

大変お手数おかけしますが、こちらのエラーの対処法教えてください。


**1/24 (23:40) 追記 **

そもそもPostgreSQLの初期化が上手くいかないようです。

下記コマンドを実行しました。
initdb /usr/local/var/postgres -E utf8 --no-locale

すると下記のように、おこられたので、
The files belonging to this database system will be owned by user "tam".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".

postgresのファルダを削除し、再度postgresを作成しようとすると
sudo rm -rf /usr/local/var/postgres
mkdir /usr/local/var/postgres

すると、postgresフォルダが勝手に作成されてうまくいかない状況です。
mkdir: /usr/local/var/postgres: File exists

こちらの原因が分かる方は、ぜひ教えてください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

initdb コマンドで、データベースの初期化 や
pg_ctl コマンドでの Postgresql の起動は、されましたか?

homebrew は、インストールしかしてくれませんので、初期設定や起動は、別途行う必要があります。

投稿2016/01/24 05:33

CHERRY

総合スコア25171

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tammax

2016/01/24 06:53

CHERRYさん、ご返信ありがといございます。 そもそもPostgreSQLの初期化が上手くいかないみたいです。 下記コマンドを実行しました。 initdb /usr/local/var/postgres -E utf8 --no-locale すると下記のように、おこられたので、 The files belonging to this database system will be owned by user "tam". This user must also own the server process. The database cluster will be initialized with locale "C". The default text search configuration will be set to "english". Data page checksums are disabled. initdb: directory "/usr/local/var/postgres" exists but is not empty If you want to create a new database system, either remove or empty the directory "/usr/local/var/postgres" or run initdb with an argument other than "/usr/local/var/postgres". postgresのファルダを削除し、再度postgresを作成しようとすると sudo rm -rf /usr/local/var/postgres mkdir /usr/local/var/postgres すると、postgresフォルダが勝手に作成されてうまくいかない状況です。 mkdir: /usr/local/var/postgres: File exists お手数おかけしますが、こちらの対処法を教えてください。
guest

0

ベストアンサー

まず最初に、postgresqlを起動してください。

投稿2016/01/24 05:06

Stripe

総合スコア2183

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tammax

2016/01/24 06:53 編集

Stripeさん、ご返信ありがといございます。 下記コマンドを実行しました。 postgres -D /usr/local/var/postgres すると、postgresql.confがないとおこられたので postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": No such file or directory 下記コマンドでファイルを作成しpostgresql.confを作成し、再度コマンドを実行しました。 touch /usr/local/var/postgres/postgresql.conf すると、権限でおこられたため、 FATAL: data directory "/usr/local/var/postgres" has group or world access DETAIL: Permissions should be u=rwx (0700). 下記コマンドで権限を変えて再度コマンドを実行しました。 chmod 700 /usr/local/var/postgres すると、今度は、PG_VERSIONのファイルがないとおこられたので FATAL: "/usr/local/var/postgres" is not a valid data directory DETAIL: File "/usr/local/var/postgres/PG_VERSION" is missing. 下記コマンドでファイルを作成し、再度コマンドを実行しました vi /usr/local/var/postgres/PG_VERSION ※ファイルの中の値は今回のバージョンである9.3が入っています すると今度はpg_controlのファイルがないとおこられた為、 postgres: could not find the database system Expected to find it in the directory "/usr/local/var/postgres", but could not open file "/usr/local/var/postgres/global/pg_control": No such file or directory 下記コマンドでファイルを作成し、再度コマンドを実行しました mkdir /usr/local/var/postgres/global touch /usr/local/var/postgres/global/pg_control すると今度はエラー内容がわからないため、ここで詰まっております。 PANIC: could not read from control file: Undefined error: 0 Abort trap: 6 -------------------------------------------------------------------------------------------------------- そもそもPostgreSQLの初期化がしてないのが原因だと思い、 下記コマンドを実行しました。 initdb /usr/local/var/postgres -E utf8 --no-locale すると下記のように、おこられたので、 The files belonging to this database system will be owned by user "tam". This user must also own the server process. The database cluster will be initialized with locale "C". The default text search configuration will be set to "english". Data page checksums are disabled. initdb: directory "/usr/local/var/postgres" exists but is not empty If you want to create a new database system, either remove or empty the directory "/usr/local/var/postgres" or run initdb with an argument other than "/usr/local/var/postgres". postgresのファルダを削除し、再度postgresを作成しようとすると sudo rm -rf /usr/local/var/postgres mkdir /usr/local/var/postgres すると、postgresフォルダが勝手に作成されてうまくいきません。 mkdir: /usr/local/var/postgres: File exists 現在、postgresの起動も、初期化も上手くいかない状態です。 お手数おかけしますが、こちらの対処法を教えてください。
Stripe

2016/01/24 14:48

postgresqlの初期化や起動は、postgresユーザーで行ってください。
tammax

2016/01/24 17:06

Stripeさん、度々ご返信ありがとうございます。 すいません、少々お聞きしたいのですが、postgresユーザーと言うのは、 下記のコマンドで作成しするpostgresユーザーと言う認識でよろしいでしょうか? createuser -P postgres なお、その場合、下記のエラーが発生し、ユザー作れないようです。 createuser: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? なお権限/usr/local/var/postgresのファイルの所有者rootだったのでを下記コマンドを実行した場合 su root initdb /usr/local/var/postgres -E utf8 --no-locale どうやらルートでは実行できないみたいです。 initdb /usr/local/var/postgres -E utf8 --no-locale initdb: cannot be run as root Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process. また、ファイルの所有者を自分(tam)に変えてコマンドを実行したい場合は sudo chown -R tam /usr/local/var/postgres initdb /usr/local/var/postgres -E utf8 --no-locale 下記のエラーが発生し、postgresファルダを削除してもpostgresフォルダが勝手に作成されてうまくいきません。 The files belonging to this database system will be owned by user "tam". This user must also own the server process. The database cluster will be initialized with locale "C". The default text search configuration will be set to "english". Data page checksums are disabled. initdb: directory "/usr/local/var/postgres" exists but is not empty If you want to create a new database system, either remove or empty the directory "/usr/local/var/postgres" or run initdb with an argument other than "/usr/local/var/postgres". 度々お手数おかけしまして、大変申し訳ございませんがどうぞ宜しくお願いします。
Stripe

2016/01/25 10:35

postgresは、OSのユーザーです。 システム環境設定のユーザとグループで普通に登録してください。
tammax

2016/01/25 15:02

Stripeさん ありがとうございます。おかけ様でpostgresqlを起動させることができました。 一週間ぐらいずっとわからず、諦めかけてきたのですが、Stripeさんのおかけで 起動させることができました。本当にありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問