postgresql - 尝试在 Linux 上初始化 PostgreSQL 数据库服务器时出现 "Permission denied"

标签 postgresql

我尝试在 Linux 中设置 PostgreSQL,但出现以下错误:

[postgres@kibearch ~]$ initdb --pgdata=/var/lib/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /var/lib/pgsql/data ... initdb: error: could not create directory "/var/lib/pgsql": Permission denied

如果我尝试使用sudo initdb --pgdata=/var/lib/psql/data/,它会说initdb不能与一起使用sudo.

以下是我所做的步骤:

  1. sudo pacman -S postgresql
  2. 使用以下命令切换到用户 postgres 用户:su - postgres
  3. 尝试初始化服务器,但出现上述错误

我能做什么?

最佳答案

作为根用户:

mkdir /var/lib/pgsql
chown postgres  /var/lib/pgsql

作为 postgres:

initdb --pgdata=/var/lib/pgsql/data

关于postgresql - 尝试在 Linux 上初始化 PostgreSQL 数据库服务器时出现 "Permission denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64216487/

相关文章:

python - Shebang 行 #!/usr/bin/python3 阻止服务器运行

ruby-on-rails - PostgreSQL 复杂索引类型和排序

sql - 可以在 PostgreSQL IN 子句中包含集合吗?

PHP 从 Postgres 意外字符中选择

sql - 生成随机电话号码的函数

sql - 如何在 postgresql 中创建类似于 oracle 的只读 View ?

mysql - 更改 Rails 中现有列的位置

PHP fatal error : Allowed memory size of xxx bytes exhausted (tried to allocate XX bytes)

ruby-on-rails - rails 4 : changing database to postgresql (from sqlite3)

postgresql - Heroku PostgreSQL Crane DB 与安装了 PostgreSQL 的 Linode 1GB