Location of postgresql database on OS X?

后端 未结 6 1760
清酒与你
清酒与你 2021-01-30 21:16

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

6条回答
  •  渐次进展
    2021-01-30 21:43

    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.

提交回复
热议问题