You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何无root权限运行PostgreSQL?解决pgtester在Fedora的套接字创建问题

Fixing pgtester's Unix Socket Permission Issue on Fedora (and Similar Distros)

I’ve run into this exact snag with pgtester on Fedora before—here’s how to get around the socket permission block without needing root access:

1. Configure pgtester to use a custom socket directory

The root problem is that /var/run/postgresql/ is owned by the root or postgres system user by default, so your regular user account can’t create sockets there. The fix is to redirect pgtester to use a directory you control:

  • First, create a dedicated socket directory in your home folder (make sure it exists before proceeding):
    mkdir -p ~/.pgtester_sockets/
    
  • Locate where pgtester initializes the temporary PostgreSQL server (either in its config files or source code). Look for settings tied to unix_socket_directories or the default socket path.
  • Override this setting to point to your new directory. For example, add this command-line flag when starting the test server:
    -c unix_socket_directories='~/.pgtester_sockets/'
    
    Alternatively, update the auto-generated postgresql.conf that pgtester uses to include this path.

2. Use an environment variable to override the socket path

If you don’t want to modify pgtester’s code directly, you can use a PostgreSQL-specific environment variable to redirect the socket location:

  • Before running your test suite, export the PGHOST variable to point to your custom directory:
    export PGHOST=~/.pgtester_sockets/
    
    This tells PostgreSQL (and pgtester’s client tools) to look for the socket in your user-owned folder instead of the system default.

3. Verify permissions and test

Double-check your custom directory has the right permissions to avoid any extra roadblocks—PostgreSQL needs read/write access, so lock it down with:

chmod 700 ~/.pgtester_sockets/

Then run your tests again. The temporary server should now create the socket in your directory without hitting permission errors.


内容的提问来源于stack exchange,提问作者honza_p

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:26:06