我想通过 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?