Pg_dump: [archiver (db)] could not connect to database "mydb": FATAL: database "mydb" does not exist

ok, following these instructions I ran:

$ PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump

in the same folder where the database is located (app_db.sql), but I keep getting:

pg_dump: [archiver (db)] connection to database "mydb" failed: FATAL:  database "mydb" does not exist

Why is this happening and what can I solve?

thank

+5
source share
1 answer

You have critically misunderstood how PostgreSQL works.

app_db.sqlnot a database, this is a database dump. A sequence of text commands that describe data in a database that can be played to create a database.

Microsoft Access .dbx SQLite3, , , . PostgreSQL - / PostgreSQL, , /var/lib/pgsql, .

, psql, :

$ createdb mydb
$ psql -f app_db.sql mydb

, , , . , mydb , , pg_hba.conf, .

unix bob :

$ sudo -u postgres createuser bob
$ sudo -u postgres createdb -O bob mydb
$ psql -f dpp_db.sql -1 -v ON_ERROR_STOP=1 mydb 

PostgreSQL .

+4

All Articles