A
A
Albadur2019-03-29 22:02:06
PostgreSQL
Albadur, 2019-03-29 22:02:06

How to import a Postresql database into an empty database?

Hello.
How to import a database?
I can log in using the su postgres -c psql command.
The list of databases contains the required empty database Empty_db I
created everything like this:

create database Empty_db; CREATE USER MyUser WITH password 'password'; GRANT All ON DATABASE Empty_db TO MyUser;

Throw a database backup there
Tried: psql -U MyUser -d Empty_db < db.sql
Answer:
psql: FATAL:  Peer authentication failed for user "MyUser"

Thank you very much in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2019-03-29
@ky0

Do the rest under postgres:
З.Ы. - I'm sorry, I didn't notice the grants. But the first paragraph does not lose its meaning from this :)

M
Melkij, 2019-03-29
@melkij

Peer authentication failed for user "MyUser"

That is, the first matching rule in pg_hba.conf was a peer check requiring the OS username to match the requested database username. Which, judging by the mistake, was not done.
What to do? Edit hba or most likely you already have password login configured when connecting via tcp / ip. That is, psql -h 127.0.0.1 ... most likely it will ask for a password.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question