【问题标题】:Cannot find pg_hba.conf and postgreql.conf file on OS X?在 OS X 上找不到 pg_hba.conf 和 postgresql.conf 文件?
【发布时间】:2015-10-08 12:13:16
【问题描述】:

我使用自制软件安装了 postgres。 我想找到他的文件 pg_hba.conf 和 postgresql.conf 但我找不到它们。

我跟着这个:

https://askubuntu.com/questions/256534/how-do-i-find-the-path-to-pg-hba-conf-from-the-shell

还有这个

http://www.kelvinwong.ca/tag/pg_hba-conf/

但我还是找不到。

【问题讨论】:

    标签: macos postgresql homebrew


    【解决方案1】:

    默认情况下,自制程序会将所有内容放在/usr/local

    所以 postgresql conf 文件将是 /usr/local/var/postgres/

    【讨论】:

    • 我在我的主目录中,当我执行 cd /usr/local/var/postgres/ 时,它说目录不存在
    • 如何到达 usr/ ?
    • postgresql 正在运行吗? (您是否启动了服务器),也可以查看brew info posgtgresql 了解更多信息
    • 是的 postgresql 正在运行,我在 finder 中输入了 /usr/local/var/postgres/ 但它给了我一个空目录。
    • 这很奇怪,当我做 brew info 时它给了我'没有可用的 posgtgres 公式'
    【解决方案2】:

    如果您可以以超级用户(通常为postgres)的身份连接到 Pg,只需SHOW hba_file; 即可查看其位置。

    否则你必须找出 PostgreSQL 是如何启动来定位它的数据目录的。

    【讨论】:

      【解决方案3】:

      最坏的情况,你可以搜索一下:

      find / -type f -name pg_hba.conf 2> /dev/null
      

      【讨论】:

        【解决方案4】:

        使用 pg admin 可以在不知道它们的位置的情况下编辑这些文件 https://dba.stackexchange.com/questions/61193/how-to-edit-postgresql-conf-with-pgadmin

        • 编辑 postgresql.conf 文件:选择Tools > Server Configuration > postgresql.conf
        • 要编辑 pg_hba.conf 文件:选择 Tools > Server Configuration > pg_hba.conf

        【讨论】:

        • 要在菜单中激活该选项,我需要连接到相关服务器,然后单击“数据库”项。
        【解决方案5】:

        这可能是找到 postgresql.conf/pg_hba.conf 文件的可能位置

        /opt/homebrew/var/postgres/postgresql.conf  
        
        /opt/homebrew/var/postgres/pg_hba.conf  
        

        【讨论】:

          【解决方案6】:

          知道 postgresql.conf 位置的另一种解决方案是启动 psql 并键入 \显示所有 然后搜索“config_file”的值。 对于我的 docker 配置,这将是 /var/lib/postgresql/data/postgresql.conf 然后我可以连接到 Docker docker exec -it postgres bash -c "export TERM=xterm-256color ; bash" 并查看其内容 cat /var/lib/postgresql/data/postgresql.conf

          【讨论】:

            【解决方案7】:

            在 MacOS Catalina 的文件夹下:

             ./Library/PostgreSQL/{postgres_version}/share/postgresql/
            

            【讨论】:

              猜你喜欢
              • 2012-12-11
              • 1970-01-01
              • 2015-07-16
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2012-06-10
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多