Postgresql user “postgres” requires password in order to create db
up vote
-1
down vote
favorite
I am running centOS 7 and trying to create a postgresql database
I entered to following to install and initiate database
yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
sudo yum install postgresql11
sudo yum install postgresql11-server
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
sudo systemctl enable postgresql-11
sudo systemctl start postgresql-11
so after this i try to create a database by entering
sudo createdb mydb
receive:
createdb: could not connect to database template1: FATAL: role "root" does not exist
so now i realize i need to be on the postgre user
and cannot create a db with this command:
sudo -u postgres createdb mydb
Recieve:
could not change directory to "/home/<user>": Permission denied
I am able to get the postgre prompt by entering the following
sudo -u postgres -i
psql
but when i enter sudo -u postgres -1
i get a new bash prompt -bash-4.2$
when i try to create a database in this prompt with sudo createdb mydb
it asks for a password for postgres and can't go on from there,
what is this password? i read that by default it shouldn't
linux postgresql centos7
add a comment |
up vote
-1
down vote
favorite
I am running centOS 7 and trying to create a postgresql database
I entered to following to install and initiate database
yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
sudo yum install postgresql11
sudo yum install postgresql11-server
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
sudo systemctl enable postgresql-11
sudo systemctl start postgresql-11
so after this i try to create a database by entering
sudo createdb mydb
receive:
createdb: could not connect to database template1: FATAL: role "root" does not exist
so now i realize i need to be on the postgre user
and cannot create a db with this command:
sudo -u postgres createdb mydb
Recieve:
could not change directory to "/home/<user>": Permission denied
I am able to get the postgre prompt by entering the following
sudo -u postgres -i
psql
but when i enter sudo -u postgres -1
i get a new bash prompt -bash-4.2$
when i try to create a database in this prompt with sudo createdb mydb
it asks for a password for postgres and can't go on from there,
what is this password? i read that by default it shouldn't
linux postgresql centos7
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am running centOS 7 and trying to create a postgresql database
I entered to following to install and initiate database
yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
sudo yum install postgresql11
sudo yum install postgresql11-server
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
sudo systemctl enable postgresql-11
sudo systemctl start postgresql-11
so after this i try to create a database by entering
sudo createdb mydb
receive:
createdb: could not connect to database template1: FATAL: role "root" does not exist
so now i realize i need to be on the postgre user
and cannot create a db with this command:
sudo -u postgres createdb mydb
Recieve:
could not change directory to "/home/<user>": Permission denied
I am able to get the postgre prompt by entering the following
sudo -u postgres -i
psql
but when i enter sudo -u postgres -1
i get a new bash prompt -bash-4.2$
when i try to create a database in this prompt with sudo createdb mydb
it asks for a password for postgres and can't go on from there,
what is this password? i read that by default it shouldn't
linux postgresql centos7
I am running centOS 7 and trying to create a postgresql database
I entered to following to install and initiate database
yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
sudo yum install postgresql11
sudo yum install postgresql11-server
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
sudo systemctl enable postgresql-11
sudo systemctl start postgresql-11
so after this i try to create a database by entering
sudo createdb mydb
receive:
createdb: could not connect to database template1: FATAL: role "root" does not exist
so now i realize i need to be on the postgre user
and cannot create a db with this command:
sudo -u postgres createdb mydb
Recieve:
could not change directory to "/home/<user>": Permission denied
I am able to get the postgre prompt by entering the following
sudo -u postgres -i
psql
but when i enter sudo -u postgres -1
i get a new bash prompt -bash-4.2$
when i try to create a database in this prompt with sudo createdb mydb
it asks for a password for postgres and can't go on from there,
what is this password? i read that by default it shouldn't
linux postgresql centos7
linux postgresql centos7
edited Nov 7 at 17:03
a_horse_with_no_name
286k45432527
286k45432527
asked Nov 7 at 16:10
Mfreeman
5912
5912
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Did you try
sudo -i -u postgres
psql
CREATE DATABASE yourbase;
c yourbase
?
Whoops, i dont know why i didnt try to create it from the prompt. that works, thanks
– Mfreeman
Nov 7 at 16:15
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Did you try
sudo -i -u postgres
psql
CREATE DATABASE yourbase;
c yourbase
?
Whoops, i dont know why i didnt try to create it from the prompt. that works, thanks
– Mfreeman
Nov 7 at 16:15
add a comment |
up vote
2
down vote
accepted
Did you try
sudo -i -u postgres
psql
CREATE DATABASE yourbase;
c yourbase
?
Whoops, i dont know why i didnt try to create it from the prompt. that works, thanks
– Mfreeman
Nov 7 at 16:15
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Did you try
sudo -i -u postgres
psql
CREATE DATABASE yourbase;
c yourbase
?
Did you try
sudo -i -u postgres
psql
CREATE DATABASE yourbase;
c yourbase
?
answered Nov 7 at 16:12
G.D
535
535
Whoops, i dont know why i didnt try to create it from the prompt. that works, thanks
– Mfreeman
Nov 7 at 16:15
add a comment |
Whoops, i dont know why i didnt try to create it from the prompt. that works, thanks
– Mfreeman
Nov 7 at 16:15
Whoops, i dont know why i didnt try to create it from the prompt. that works, thanks
– Mfreeman
Nov 7 at 16:15
Whoops, i dont know why i didnt try to create it from the prompt. that works, thanks
– Mfreeman
Nov 7 at 16:15
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53193382%2fpostgresql-user-postgres-requires-password-in-order-to-create-db%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown