前提・実現したいこと
Ruby on railsの開発環境として
homebrewを用いて、postgreSQLをインストールしたところ
パスワードを求められてしまい、psqlコマンドが実行できずに困っています。
インストールは
homebrewを用いてインストールしたのち
以下コマンドで初期化を行い、posgreSQL を起動させました。
$ brew install postgresql $ initdb /usr/local/var/postgres/ -E utf8 --no-locale $ brew services start postgresql ==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
listやpsコマンドで確認しましたが、起動自体は問題なさそうです
$ var naoto$ brew services list Name Status User Plist postgresql started naoto /Users/naoto/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ ps aux | grep postgresql naoto 51284 0.0 0.0 4278280 832 s000 S+ 7:32PM 0:00.01 grep postgresql naoto 51075 0.0 0.1 4472648 7708 ?? S 7:27PM 0:00.07 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres
発生している問題・エラーメッセージ
postgres自体の起動は問題ないことを確認し
psqlコマンドを打つと
$ psql -l Password for user naoto: psql: FATAL: password authentication failed for user "naoto"
となってしまい、OSのパスワードを入力しても実行することができません。
過去の質問でpostgresユーザーでログインしてから行うとありましたので
(postgresユーザーでpsqlコマンドが成功しません)
$ su - postgres Password: naoto:~ postgres$
と、postgresユーザで入り実行してみる
この時のパスワードは,システム環境設定>ユーザーとグループ から、
postgresユーザのパスワードを設定し、使用
- アカウント名:postgres
- パスワード:postgres
無事入れたので実行しようとしたところ
もう一度、posgresユーザーについてのパスワードを求められ、
先ほど入力したパスワード(postgres)を入力しても、弾かれてしまいまいました
naoto:~ postgres$ psql -l Password for user postgres: psql: FATAL: password authentication failed for user "postgres"
試したこと
認証設定を行なっているpg_hba.confを確認しましたが
**turst設定となっており、本来ならパスワードは聞かれないはずでは?**となり
行き詰まっています。
念の為、再起動(brew services restart postgresql)
を行い、試しましたが、結果は変わらず。
$ sudo vi /usr/local/var/postgres/pg_hba.conf # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust # Allow replication connections from localhost, by a user with the # replication privilege. local replication all trust host replication all 127.0.0.1/32 trust host replication all ::1/128 trust
また、再インストールを
下記のページをもとに行いましたが、結果は変わりませんでした
[MacOS] PostgreSQL の全バージョンをアンインストールする方法 ~ Homebrew 編
- brew uninstallによるアンインストール
- ログデータの消去
- pidファイルの消去
brew uninstall --force postgresql rm -rf /usr/local/var/postgres rm -rf /usr/local/var/postgres/postmaster.pid
補足情報(FW/ツールのバージョンなど)
開発環境として
・postgreSQL 11.3
・mac 10.14.5
を使用しています。
外部からのアクセスや仮想環境ではありません
今までMANP環境のphpmyadminしか使ったことがなく、
苦戦しながら進めております。
見当違いな点等ありましたら、指摘していただけると助かります。
よろしくお願いします。
追記(6/20)
installしてから、
postgresのDBへパスを通すこともやっていましたので追記します
$ echo 'export PGDATA="/usr/local/var/postgres"' >> ~/.bash_profile $ source .bash_profile
さらに、問題のパスワードですが
パスワードを記入なしで進むと下記エラーになり、
パスワードを変更するためのpsqlコマンドも打てない状態です。
naoto:~ postgres$ psql -l psql: fe_sendauth: no password supplied
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。