コンピューター上のすべてのデータを失った後(Appleストアですべてを消去する必要がありました)、コマンドを指定してHomebrewを使用してMacにpostgresをインストールしましたbrew install postgres
。次に、サーバーを起動し(サーバーが起動したことを確認して)、コマンドを使用して、postgresを使用するSinatraプロジェクトのデータベースを作成しようとしました。
createdb db_development
ただし、次のエラーが発生しました。
createdb: 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 "/var/pgsql_socket/.s.PGSQL.5432"?
オンラインで検索した後、次のinitdbコマンドを実行する必要がある可能性があることがわかりました
initdb /usr/local/var/postgres
しかし、私がそれをしたとき、私はこのメッセージを受け取りました
initdb /usr/local/var/postgres
The files belonging to this database system will be owned by user "braindead".
This user must also own the server process.
The database cluster will be initialized with locale "en_CA.UTF-8".
The default database encoding has accordingly been set to "UTF8".
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は、このエラーが発生すると同時にサーバーが起動したことを確認したのcould not connect to database postgres: could not connect to server: No such file or directory
でしょうか。また、これを修正するにはどうすればよいでしょうか。
プロジェクトのREAD.meは言った
bundle install
createdb db_development
rake db:migrate
MacOSに付属のpostgresに接続しようとするか、PG環境変数が設定されていません。試してみてください:createdb -h localhost db_development
これらはpostgresのpostgres環境変数です。また、PostgresAppはMacでPostgresqlを使用するための非常に便利な方法です
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加