0

So, I have a Pyramid app with a postgres database on my local machine. I did a pg_dump to get a dump of the data in my database, called pg_dump_2014-04-22. I then git pushed this file, and did a git pull in the VPS to get the file.

Now, I have already installed postgres on my VPS. When I sudo -u postgres psql on my VPS, I can connect to it but there are no relations (naturally).

Both my username and database name are postgres.

So, I tried psql postgres < pg_dump_2014-04-22, but this gives the error psql: FATAL: role "root" does not exist.

I also tried pg_restore -h localhost -U postgres -d postgres pg_dump_2014-04-22, and that prompts me for my password, but then throws the error pg_restore: [archiver(db)] connection to database "postgres" falied: FATAL: password authentication failed for user postgres"

What am I missing here?

2
  • (temporally) add a line local postgres postgres trust to your pg_hba.conf file. Commented Apr 22, 2014 at 12:26
  • help.ubuntu.com/community/PostgreSQL Commented Apr 22, 2014 at 13:00

1 Answer 1

1

You first have to create a user and the database where you want to import your dump

su postgres

createuser root

createdb yourdb

Then import the dump with

psql -d yourdb -f pg_dump_2014-04-22

Sign up to request clarification or add additional context in comments.

8 Comments

There is no need to create a root user in Postgres.
True but since he is trying to import ad root that's why I have included the user creation
It would be much better to simply provide the correct postgres username to psql using the -U option.
Thanks for the tips, I have followed these steps but am getting an UTF-8 encoding error. (I think, actually it messed up the terminal's output in the VPS so I can't read it properly). Would something like this work? createdb mydb -E utf-8
Give it a go. Since you're importing you can still drop and recreate the db
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.