AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[postgresql](unix)

Martin Hope
John
Asked: 2022-10-28 09:21:51 +0800 CST

为什么在我禁用 ident 身份验证之前,基于密码的身份验证不能在 postgresql 中工作?

  • 5

我刚刚从 Fedora 36 上的 repos 安装了 postgresql 和 pgadmin。我设置了初始 postgres 角色和数据库,并使用 postgres 用户登录

sudo su - postgres
psql

从那里,我使用加密密码设置了一个新用户:CREATE ROLE john WITH ENCRYPTED PASSWORD '123';

我还将这一行添加到我的pg_hba.conf:

host    all             all             127.0.0.1/32            scram-sha-256

现在,从 unix 开始,作为 root 用户,如果我尝试: psql -U john -W -h 127.0.0.1,我会收到此错误:

psql: error: connection to server at "127.0.0.1", port 5432 failed: FATAL:  Ident authentication failed for user "john"

pgadmin 也无法登录数据库并显示类似的错误消息。

但是,如果我进入pg_hba.conf并禁用此行:

host    all             all             127.0.0.1/32            ident

突然之间,我可以从 pgadmin 和psql -U john -W -h 127.0.0.1root 用户的命令登录。

难道我做错了什么?为什么我需要完全禁用 ident auth 才能正常工作?我没有看到任何强制密码验证的方法,而不是来自 psql 客户端或 pgadmin 的 ident 验证。

编辑 - 这是我的 pg_hba.conf:

local   all             all                                     peer
#host    all             all             127.0.0.1/32            ident
host    all             all             ::1/128                 ident
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident
host    all             all             127.0.0.1/32            scram-sha-256

这基本上是来自 repos 的 postgres 附带的默认设置,但我:

  • 注释掉ident一行
  • 添加了最后一行
postgresql
  • 1 个回答
  • 18 Views
Martin Hope
naarter
Asked: 2022-03-28 07:10:30 +0800 CST

Slackware 和 postgres

  • 0

我想通过 Slackbuild 安装 postgres 和 psql,我这样做了。安装后,我尝试按照 Slackbuild 自述文件中的建议运行该命令,但在按说明运行时出现错误。

su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"

应该是一行,从您复制和粘贴的内容来看,您将 su 放在一行上,然后将其余命令放在另一行上。我不确定这是否只是您的格式问题,但看起来情况并非如此。此外,您报告的错误消息似乎支持您没有在一行上给出命令的想法,因此没有以正确的用户身份运行命令等。我在一个文件上运行它。我尝试通过源代码安装它,但它非常复杂,所以我回到通过 Slackbuild 安装它。一切都很好,直到我需要运行:代码:

su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"

这就是我尝试以多种方式运行上述命令时得到的结果。它不执行,我相信这就是 Postgres 不工作的原因。我决定搭上这门课,学习如何使用 Slackware、Linux、PSQL 和 Full Stack,以最大限度地利用我的知识库并为 Slackware 项目做出贡献。在通过此博客安装 postgres 时,我注意到某些重要但过时的程序不在我计划添加的 Sbo 网站中。这家伙在 Slackware 上有一些有趣的博客:http://www.pmoghadam.com/homepage/HT...esql-epkg.html 下面是我尝试执行命令的过程,你认为发生了什么?

bash-5.1$ su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ sudo postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.
bash-5.1$ su - postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su - postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Password: 
su: Authentication failure
bash-5.1$ su postgres -c init -D /var/lib/pgsql/14/data --locale-en_US.UTF-8 -A md5 -W
su: invalid option -- 'D'
Usage: su [options] [-] [username [args]]

Options:
  -c, --command COMMAND         pass COMMAND to the invoked shell
  -h, --help                    display this help message and exit
  -, -l, --login                make the shell a login shell
  -m, -p,
  --preserve-environment        do not reset environment variables, and
                                keep the same shell
  -s, --shell SHELL             use SHELL instead of the default in passwd

If no username is given, assume root.



bash-5.1$ su
Password: 
bash-5.1# postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.
bash-5.1# su - postgres

We are upping our standards ... so up yours.
                -- Pat Paulsen for President, 1988

postgres@Bern:~$ postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
2022-03-27 14:57:17.257 GMT [32152] FATAL:  unrecognized configuration parameter "initdb _D /var/lib/pgsql/14/data __locale"
postgres@Bern:~$ postgres -c initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W
2022-03-27 14:57:30.413 GMT [32155] FATAL:  -c initdb requires a value
postgres@Bern:~$

我不知道为什么这不起作用,因为我听了并遵循了神圣的读物。我相信 Linux 的方式,更重要的是 Slackware 作为一个神灵和神奇的软件。我会继续寻找结果。

6.0 / import_db.sh

#!/usr/bin/env sh

dropdb sqlzoo
createdb sqlzoo
psql sqlzoo < data/create_tables.sql
ls

在需要使用 psql 的项目文件的目录下。我收到以下错误:

bash-5.1# cd skeleton
bash-5.1# ls
Gemfile  Gemfile.lock  data  database  import_db.sh  lib  logfile  spec
bash-5.1# ./import_db.sh 
dropdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
createdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
Gemfile  Gemfile.lock  data  database  import_db.sh  lib  logfile  spec
bash-5.1# startdb
bash: startdb: command not found
bash-5.1# initdb
initdb: error: no data directory specified
You must identify the directory where the data for this database system
will reside.  Do this with either the invocation option -D or the
environment variable PGDATA.
bash-5.1# psql
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
bash-5.1# 
bash-5.1# nano import_db.sh 

为什么会出现这个错误?为什么我不能使用 psql?

users postgresql
  • 2 个回答
  • 133 Views
Martin Hope
Dolphin
Asked: 2021-12-13 20:50:38 +0800 CST

postgresql-devel 和 postgresql 的版本关系是什么

  • -1

postgresql-devel 版本和postgresql有关系吗?它有版本矩阵吗?如果我安装了 postgresql 13,如何在 centos 中安装 postgresql 13 映射的 postgresql-devel 版本?我看了官方文档,没有发现任何关系。我在 centos 中安装了 postgresql 13:

postgresql13-libs-13.3-1PGDG.rhel7.x86_64
postgresql13-13.3-1PGDG.rhel7.x86_64
postgresql13-server-13.3-1PGDG.rhel7.x86_64

但是当我使用这个命令安装 postgresql-devel 时:

dnf install postgresql-devel

显示包冲突:

 file /usr/lib64/libpq.so.5 from install of postgresql-libs-9.2.24-7.el7_9.x86_64 conflicts with file from package libpq5-14.0-42PGDG.rhel7.x86_64

9.2.24-7.el7_9映射到 postgresql 9 的版本?如何安装 postgresql 13 映射的 postgresql-devel?

centos postgresql
  • 2 个回答
  • 237 Views
Martin Hope
Archer Hu
Asked: 2020-03-11 23:13:25 +0800 CST

在 CentOS7 上安装 postgresql11 时出现异常的 repos 错误

  • 3

我试图在 CentOS7 上安装 postgresql11。我在官方网站上找到了安装说明: https ://www.postgresql.org/download/linux/redhat/

然后我按照它的步骤选择以下参数:

1.version: 11
2.platform: RedHat Enterprise,CentOS, Scientific or Oracle version 7
3.architecture: x86_64

得到了安装资源 RPM 的命令:

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

我在服务器上成功运行它。然后我尝试运行安装客户端软件包的命令:

yum install postgresql11

执行此命令时出现以下错误:

File contains parsing errors: file:///etc/yum.repos.d/pgdg-redhat-all.repo
    [line 196]: [pgdg96-updates-debuginfo]k
    [line 203]: [pgdg95-updates-debuginfo]k

当我尝试删除这个包使用命令时遇到了同样的错误:

yum erase pgdg-redhat-repo

我在 /etc/yum.repos.d 使用命令中找不到任何内容:

cd /etc/yum.repos.d/ && grep pgdg-redhat-all.repo ./*

我已经在谷歌搜索过这个错误,似乎没有人遇到这个错误。有谁知道如何解决这个问题?

centos postgresql
  • 1 个回答
  • 1231 Views
Martin Hope
Praveenkumar Beedanal
Asked: 2020-02-05 02:49:05 +0800 CST

如何在shell脚本中顺序运行两个sql命令

  • 0

我想按顺序运行这两个 sql 命令,但我无法实现。

这是我的shell脚本

#! /bin/bash

gsutil cp gs://api-bucket-germany/order_status.csv ./order_status.csv

psql -d apidbgermany -U apidbgermany << EOF

DELETE FROM apidbgermany.order_status
\copy apidbgermany.order_status from './order_status.csv' delimiter ',' CSV;
EOF

它正在执行复制然后删除。

shell-script postgresql
  • 1 个回答
  • 192 Views
Martin Hope
Chris Stryczynski
Asked: 2019-06-10 04:03:19 +0800 CST

是否可以在引用不同 nixpkg 提交的不同 Nixos 主机之间移植可执行文件?

  • 0

我试图通过将可执行文件直接从一台 Nixos 主机复制到另一台主机来使其正常工作。它仅在其中一台主机上工作/执行。

在旧主机上(它工作的地方):

[root@XenonKiloCranberry:~/blog]# ldd app
    linux-vdso.so.1 (0x00007fffd68fb000)
    libm.so.6 => /nix/store/7gx4kiv5m0i7d7qkixq2cwzbr10lvxwc-glibc-2.27/lib/libm.so.6 (0x00007f591bf32000)
    libpq.so.5 => /nix/store/sf3jq8d81gx6fmxsi0mhagpgsgpnxf6m-postgresql-9.6.12-lib/lib/libpq.so.5 (0x00007f591bd03000)

在新主机上找不到共享库:

[root@XenonKiloCranberry:~/blog]# ldd /root/blog/app
    linux-vdso.so.1 (0x00007fff6cb89000)
    libm.so.6 => /nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/lib/libm.so.6 (0x00007f927e00f000)
    libpq.so.5 => not found


我确实libpq.so在新主机的 postgresql-lib 目录中看到了一个文件:

[root@XenonKiloCranberry:~/blog]# ll /nix/store/1m0kd7v8yvf5vdmd2jm16w4aal234114-postgresql-9.6.13-lib/lib/libpq.so
lrwxrwxrwx 1 root root 12 Jan  1  1970 /nix/store/1m0kd7v8yvf5vdmd2jm16w4aal234114-postgresql-9.6.13-lib/lib/libpq.so -> libpq.so.5.9
[root@XenonKiloCranberry:~/blog]# ll /nix/var/nix/profiles/system/sw/lib/libpq.so.5
lrwxrwxrwx 1 root root 80 Jan  1  1970 /nix/var/nix/profiles/system/sw/lib/libpq.so.5 -> /nix/store/1m0kd7v8yvf5vdmd2jm16w4aal234114-postgresql-9.6.13-lib/lib/libpq.so.5

我已经[glibc gmp5 postgresql postgresql.lib zlib.dev zlib.out]在我的environment.systemPackages.

postgresql dynamic-linking
  • 1 个回答
  • 303 Views
Martin Hope
Tim
Asked: 2019-03-21 15:30:26 +0800 CST

为什么 postgresql 服务器有一个 `localhost:57504` 到 `localhost:57504` UDP“连接”?

  • 2
$ sudo netstat -ap | grep postg
tcp        0      0 localhost:postgresql    0.0.0.0:*               LISTEN      1567/postgres       
udp        0      0 localhost:57504         localhost:57504         ESTABLISHED 1567/postgres       
unix  2      [ ACC ]     STREAM     LISTENING     27116    1567/postgres        /var/run/postgresql/.s.PGSQL.5432

为什么 postgresql 服务器有一个localhost:57504到localhost:57504UDP 的“连接”?这意味着什么?

谢谢。

postgresql socket
  • 1 个回答
  • 846 Views
Martin Hope
mencherid
Asked: 2019-03-16 05:24:05 +0800 CST

在 Mint 19.1 上移动 postgresql 数据文件夹

  • 0

我想从我的 Linux Mint 19.1 Cinnamon 上的 SSD 和 HDD 中移动我的数据文件夹。

我已经从https://www.enterprisedb.com/downloads/postgres-postgresql-downloads版本 Linux x86-64 10.7 安装了 postgresql。我找到了这篇文章:https ://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-18-04和试图跟随,但我被困住了。

我在这里有我的数据目录:/opt/PostgreSQL/10/data(来自 psql -> SHOW data_directory)我的 postgresql.conf 也在这个数据目录中(/opt/PostgreSQL/10/data/postgresql.conf) . 我可以移动我的数据目录,但我也会移动 conf 文件。我只是看不到,如果此配置位于新位置,postgresql 将如何知道新配置。

linux-mint postgresql
  • 1 个回答
  • 296 Views
Martin Hope
Server Fault
Asked: 2018-08-03 09:27:01 +0800 CST

将 postgres 数据库转储到单独的文件中

  • 2

我继承了一个 postgres 数据库(我对此几乎没有经验)并试图找出一种方法来转储/备份它。我一直在阅读有关它的文档,并且可以将 DB 转储到单独的文件中,但想知道为什么我不能 dump template0. 据我了解,这是一种“默认”模板,如果修改,它似乎很重要。为什么这不起作用?

test# export PGPASSWORD="xxxxxxx"; for database in `psql --username=postgres --command='\list' -h localhost | grep '^ [a-zA-Z0-9]' | awk '{print $1};'`; do pg_dump -U postgres ${database} > ${database}.sql; done                    

pg_dump: [archiver (db)] connection to database "template0" failed: FATAL:  database "template0" is not currently accepting connections
backup postgresql
  • 1 个回答
  • 540 Views
Martin Hope
Nodon
Asked: 2018-06-22 23:07:27 +0800 CST

如何在 Debian 中安装 npgsql?

  • 0

如何安装npgsql到 Debian?Google 只给我一篇如何安装 PostgreSQL 的文章。

debian postgresql
  • 1 个回答
  • 236 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve