Install PostgreSQL on Linux, I met the error: "-bash: /usr/local/pgsql/bin/initdb: Permission denied", Why?

Viewed 157

My Cloud OS is OpenEuler, Just like CentOS. I want to install postgresql14.2, I do just like below:

[root@ecs ~]# dnf -y update
[root@ecs ~]# dnf install -y bc tmux readline-devel zlib zlib-devel tar vim
[root@ecs ~]# groupadd postgres
[root@ecs ~]# useradd -g postgres postgres
[root@ecs ~]# passwd postgres
[root@ecs ~]# wget https://ftp.postgresql.org/pub/source/v14.2/postgresql-14.2.tar.gz
[root@ecs ~]# tar -xzvf postgresql-14.2.tar.gz
[root@ecs ~]# cd postgresql-14.2
[root@ecs ~]# ./configure 
[root@ecs ~]# make 
[root@ecs ~]# make install 
[root@ecs ~]# mkdir /usr/local/pgsql/data 
[root@ecs ~]# chown -R postgres:postgres /usr/local/pgsql/data
[root@ecs ~]# su - postgres
[postgres@ecs ~]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

When I run the command:

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

I meet the error:

-bash: /usr/local/pgsql/bin/initdb: Permission denied

I don't know how to deal with this kind of error, Please give me some advice. Thanks a lot!

1 Answers

I solved this trouble, use:

chown postgres:postgres /usr/local/pgsql -R

replace

chown -R postgres:postgres /usr/local/pgsql/data
Related