I\'m sure this has been answered but I cannot seem to find an answer.
I installed postgresql using Homebrew (brew install postgresql) which installed to /usr/local/Cella
System: MAC OS X 10.9.5
Now (ver. 9.4) this is under the dir called /Library/PostgreSQL
If you go there, open the folder named as the ver. of your PG and then go to the folder data
you will find your DB. This is really a set of many-many-many different both binary and text files (most of those are named with long numbers like "92891
" or so...
Note, to open the data
folder you have to open its properties (right mouse click and select "Get info") and allow you to read this folder.
I wdn't suggest you to open the RW permissions if you aren't familiar with this as any smallest change can affect you whole DB which is would be sad..
Good luck!
Run the following query:
SHOW DATA_DIRECTORY;
initdb just sets up the directory structure and such that is needed to create new databases. To create a database, use createdb:
SYNOPSIS
createdb [ option... ] [ dbname ] [ description ]DESCRIPTION
createdb creates a new PostgreSQL database.Normally, the database user who executes this command becomes the owner of the new database. However a different owner can be specified via the -O option, if the executing user has appropriate privileges.
createdb is a wrapper around the SQL command CREATE DATABASE [create_database(7)]. There is no effective difference between creating databases via this utility and via other methods for accessing the server.
initdb
is sort of like creating a new file system on a hard disk: first you create the file system (initdb
), then you create a files and directories (createdb
).
The actual database files will be under /usr/local/var/postgres
after you create the database. So, just create a database and then see what's new or changed under /usr/local/var/postgres
. There isn't a single "dbname.db" file or anything like that, each database is a collection of files with names that are only meaningful to the database server.
In my case (not homebrew) the data location is found in this file /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
<array>
<string>/Users/me/bin/postgres/bin/postmaster</string>
<string>-D/Users/me/data/postgres</string>
</array>
The current behavior of the different installers is documented at https://wiki.postgresql.org/wiki/Installers/Mac_OS_X#Known_Installers. Homebrew does not, as someone commented above, put the data under /Library
.
Since there are three different libraries in Mac, developers are usually confused with the three scenarios. However, you can find out your PostgreSQL directory with one of the two methods on the Mac Computer.
1. Directory--Absolute Path
1). Scroll up your mouse to the left top of Mac Screen
2). Click the menu "Go"
3). Select the "Go to Folder..."
4). Input the path
/Users/username/Library/Application Support/Postgres
Please change "username" to your name such as "jack" listed as follows.
/Users/jack/Library/Application Support/Postgres
5). Choose the button "Go" to the directory of Postgres.
You will eventually find out Postgres.
2. Find the directory step by step
1). Scroll up your mouse to the left top of Mac Screen.
2). Click the menu "Go".
3). Select the button "Library"
4). Double click the file holder "Application Support".
5). Find out "Postgres" according to the alphabetic order.
Cheers,
Mike