簡體   English   中英

無法在PostgreSQL中創建b

[英]Cannot createdb in postgresql

我正在嘗試使用PostgreSQL作為數據庫啟動Ruby on Rails應用程序,因為一旦完成此站點,我將其推廣到另一個擁有259K關注者的博客,而我只是想預測一下我的新網站的用戶群是否得到大。

無論如何,我首先遵循了本教程: https : //gorails.com/setup/osx/10.11-el-capitan 但是,當我使用PostgreSQL開發應用程序時,數據庫將無法創建。

所以我退后一步,嘗試卸載並重新安裝postgres,更新了我的自制軟件,現在我在關注這個新教程: https : //www.codefellows.org/blog/three-battle-tested-ways-to-install- PostgreSQL的#macosx

我正在執行步驟:根據您的用戶名創建默認數據庫。

我運行命令並得到以下信息:

Mayas-MacBook-Air:~ mayaah$ which psql
/usr/local/bin/psql
Mayas-MacBook-Air:~ mayaah$ createdb `whoami`
createdb: could not connect to database template1: 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"?

我不知道從這里做什么。 我已經在Google上廣泛搜索了這個問題,卻找不到答案。 我能想到的唯一可能的問題是,我的Mac上幾乎沒有剩余空間,因為我看到了一些關於“共享空間”的東西,但我不太了解。

如果對此有任何見解,特別是使用特定的分步命令行說明,將非常有幫助。 謝謝!

編輯:現在我找到了本教程: http : //exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/

試圖運行

postgres -D /usr/local/var/postgres

收到:

LOG:  skipping missing configuration file    "/usr/local/var/postgres/postgresql.auto.conf"
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.5.

我也不知道從這里做什么。

首先,您安裝了PostgreSQL版本9.3,然后將其卸載並安裝了版本9.4。 但是一些舊文件保留在那里,而PostgreSQL 9.4與它們不兼容。 如果您不需要9.3版本的任何數據,則可以刪除它們並為9.4版本初始化新設置:

rm -rf /usr/local/var/postgres
initdb /usr/local/var/postgres -E utf8

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM