Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL with Homebrew on Mac

First I use homebrew and install postgresql and I get this success message:

==> Summary 🍺 /usr/local/Cellar/postgresql/9.2.2: 2819 files, 39M, built in 68 seconds

Then I need to run this command:

initdb `brew --prefix`/var/postgres -E utf8

But this is the message I get: What should I do with this? Also running on OSX 10.8.2

The files belonging to this database system will be owned by user "JonyIve". This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8". The default text search configuration will be set to "english".

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".

like image 957
Bohn Avatar asked Jan 24 '13 20:01

Bohn


People also ask

Does PostgreSQL work on Mac?

MacPorts. PostgreSQL packages are also available for macOS from the MacPorts Project. Please see the MacPorts documentation for information on how to install ports. A list of PostgreSQL packages can be found using the portfiles search tool on the MacPorts website.

How do I start PostgreSQL on Mac terminal?

`psql` on Terminal To get to the PostgreSQL terminal, open your terminal, start the database services ( brew services start postgresql) , then run psql . Thank you!


2 Answers

Assuming this is a new installation and not a re-installation I think solving your problem is as simple as:

initdb `brew --prefix`/var/postgres/data -E utf8

Typically the data directory is called "data' and is underneath the postgresql home directory. this allows for the possibility of sharing log file access and the like.

like image 75
Chris Travers Avatar answered Oct 13 '22 01:10

Chris Travers


If you know that you can do this without breaking anything, another option is always just to remove the directory as per the message

remove or empty the directory "/usr/local/var/postgres"

Via

rm -rf /usr/local/var/postgres

like image 44
youngrrrr Avatar answered Oct 13 '22 00:10

youngrrrr