postgresql 数据库在 OS X 上的位置?
我确信这个问题已经得到解答,但我似乎找不到答案。
我使用 Homebrew (brew install postgresql) 安装了 postgresql,它安装到 /usr/local/Cellar/postgresql。根据我的说明,我这样做了:
If this is your first install, create a database with:
initdb /usr/local/var/postgres
据我了解,initdb 创建了一个新的数据库集群。因此,当我执行上述操作时,数据库名称和数据库本身是“postgres”,还是所有 postgresql 数据库都需要的所有必要位?
实际的数据库最终存放在哪里?我是 postgresql 新手,正在寻找作为数据库的文件或二进制文件。 那么,数据库在哪里?当我创建一个新数据库时,它会去哪里?
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/Cellar/postgresql. Afterwords per the instructions I did this:
If this is your first install, create a database with:
initdb /usr/local/var/postgres
As I understand it, initdb creates a new cluster of databases. So when I did the above is "postgres" the database name and the database itself or just all the necessary bits that all postgresql databases will need?
Where does the actual database end up living? I am new to postgresql and looking for a file or binary that is the database. So, where is the database, and when I create a new one where does it go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
运行以下查询:
Run the following query:
由于 Mac 中存在三种不同的库,因此开发人员通常对这三种情况感到困惑。但是,您可以在 Mac 计算机上使用两种方法之一找到您的 PostgreSQL 目录。
1.目录——绝对路径
1).将鼠标向上滚动到 Mac 屏幕的左上角
2)。单击菜单“开始”
3)。选择“转到文件夹...”
4)。输入路径
/Users/用户名/Library/Application Support/Postgres
请将“用户名”更改为您的名字,例如下面列出的“jack”。
/Users/jack/Library/Application Support/Postgres
5).选择“Go”按钮进入 Postgres 目录。
你最终会发现 Postgres。
2.一步步找到目录
1).将鼠标向上滚动到 Mac 屏幕的左上角。
2)。单击菜单“前往”。
3)。选择“库”按钮
4)。双击文件持有者“应用程序支持”。
5)。按照字母顺序查找“Postgres”。
干杯,
迈克
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
系统:MAC OS X 10.9.5
现在(版本 9.4)位于名为
/Library/PostgreSQL
的目录下如果你去那里,打开名为 ver. 的文件夹。你的PG,然后进入文件夹
data
你会找到你的DB。这实际上是一组很多很多不同的二进制文件和文本文件(其中大多数都以长数字命名,例如“92891
”等等......请注意,要打开
data
文件夹,您必须打开其属性(单击鼠标右键并选择“获取信息”)并允许您读取该文件夹。如果您不熟悉这一点,我不建议您打开 RW 权限,因为任何最小的更改都会影响您的整个数据库,这将是悲伤的..
祝您好运!
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!
就我而言(不是自制程序),数据位置可以在此文件
/Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
中找到In my case (not homebrew) the data location is found in this file
/Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
不同安装程序的当前行为记录在 https://wiki.postgresql.org/ wiki/Installers/Mac_OS_X#Known_Installers。正如上面有人评论的那样,Homebrew 不会将数据放在
/Library
下。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
.使用
SHOW DATA_DIRECTORY;
,位置是Using
SHOW DATA_DIRECTORY;
, the location isinitdb
只是设置目录结构,这样需要创建新的数据库。要创建数据库,请使用createdb
:initdb
有点像在硬盘上创建新的文件系统:首先创建文件系统 (initdb
),然后创建文件和目录 (创建b
)。创建数据库后,实际的数据库文件将位于
/usr/local/var/postgres
下。因此,只需创建一个数据库,然后查看/usr/local/var/postgres
下有哪些新增内容或更改。没有单个“dbname.db”文件或类似的文件,每个数据库都是其名称仅对数据库服务器有意义的文件的集合。initdb
just sets up the directory structure and such that is needed to create new databases. To create a database, usecreatedb
: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.