繁体   English   中英

initdb:错误:无法创建目录“./PostgreSQL”:权限被拒绝

[英]initdb: error: could not create directory “./PostgreSQL”: Permission denied

这是我第一次在我的 windows 8.1 上设置数据库(postgresql 12)

从这个领域的许多相关问题中努力寻找解决方案已经 4 天了,但没有成功找到答案(无论我不理解它们还是它们在我的情况下不起作用)。

所以,在这里,我将一步一步地解释我做了什么以及我在每个阶段遇到了什么错误(它们可能不会相互影响,但我会提到所有错误):

当我以管理员身份安装 PostgreSQL 时,在该过程结束时我收到此错误:“无法将 SQL 模块加载到数据库集群中”我重新安装了两次,但似乎每次都弹出。 在这里,在这篇文章中,我发现有人遇到了同样的问题,但我从技术上不明白解决方案是什么,不幸的是: Failed to load sql modules into the database cluster during PostgreSQL Installation. 因此,我只是跳过它,一切似乎都很好。

然后我在高级系统设置中设置 PATH -> 环境变量(在用户变量和系统变量框中),如下所示:“;C:\Program Files\PostgreSQL\12\bin;C:\Program Files\PostgreSQL\12 \lib"

在这一步之后,我使用 ctrl+R 打开一个终端并输入 cmd.exe 然后输入以下代码:

> cd C:\Program Files\PostgreSQL\12\bin
> initdb -U postgres -A password -E utf8 -W -D .\PostgreSQL\12\data

在这里,我收到了这条消息:

The files belonging to this database system will be owned by user "pc".
This user must also own the server process.

The database cluster will be initialized with locale "English_United States.1252".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password:
Enter it again:

输入密码后,我收到此错误:

    The files belonging to this database system will be owned by user "pc".
This user must also own the server process.

The database cluster will be initialized with locale "English_United 
States.1252".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password:
Enter it again:

creating directory /PostgreSQL/12/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... windows
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Tehran
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctl -D ^"^\PostgreSQL^\12^\data^" -l logfile start

但是在输入建议的代码时(无论使用日志文件还是其他文件名),我都会收到以下消息:

waiting for server to start....Access is denied.
 stopped waiting
pg_ctl: could not start server
Examine the log output.

另一方面,当我尝试 pgAdmin4 浏览器界面时,当我在弹出的 window 中右键单击服务器-->创建-->服务器时,我填写了以下字段:

在常规选项卡上,我将“名称”框填写为“dbserver”,我的“用户名”设置为“postgres”,然后在连接选项卡上,我将“主机”设置为“本地主机”和“密码”,就像我之前设置的一样。

这是我得到的错误:

Unable to connect to server: could not connect to server: Connection refused (0x0000274D/10061) Is 
the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not 
connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" 
(127.0.0.1) and accepting TCP/IP connections on port 5432?

有人可以帮我解决这个问题吗?

谢谢

所以,我找到了答案,我想分享它。 我打开 postgres.conf 文件并注释掉 logging_collector、log_directory 和 log_destination。 我保存了文件。

然后在终端中,我输入了如下建议的代码:

pg_ctl -D ^"^\PostgreSQL^\12^\data^" start

服务器启动了。

现在在 pgAdmin4 浏览器中,问题也消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM