New install of PostgreSQL and pgAdmin on Ubuntu 11.04 64-bit.
On restoring a database schema with pgAdmin, it launches the following command:
/usr/bin/pg_restore --host opusdb --port 5432 --username postgres --dbname \"mydb\" --verbose "mydb.backup"
pg_restore: connecting to database for restore
pg_restore: [archiver (db)] connection to database ""mydb"" failed: FATAL: database ""mydb"" does not exist
pg_restore: *** aborted because of error
Process returned exit code 1.
The problem is due to the \" before and after the database name. The following works on the command line (note the absent \ characters):
/usr/bin/pg_restore --host opusdb --port 5432 --username postgres --dbname "mydb" --verbose "mydb.backup"
Not sure if pgAdmin is suddenly using a different syntax, or pg_restore doesn't understand the \" anymore. Could it be in any way related to the 64-bit installation of Ubuntu?
Obviously this is a problem with the particular pgadmin3 version: osdir.com/ml/ubuntu-bugs/2011-05/msg30089.html
The next version shouldn't have this problem anymore.
Related
I tried to restore a database from the command line using
pg_restore --host localhost --port 5434 __username "postgres" --dbname "database_name" -- verbose ""file_path"
But I keep getting the same message
pg_restore archiver unsupported version (1.13) in file header
BTW: I'm using Postgres 9.6
Is there another way to solve it without upgrading PostgreSQL?
PGPASSWORD=mypassword pg_dumpall -h
mydbname.postgres.database.azure.com -p 5432 -U admin#mydbname
pg_dump: [archiver (db)] connection to database "azure_maintenance"
failed: FATAL: permission denied for database "azure_maintenance"
DETAIL: User does not have CONNECT privilege. pg_dumpall: pg_dump
failed on database "azure_maintenance", exiting
How would you backup all db's in Azure Postgresql hosted service?
Since PostgreSQL 12.0 pg_dumpall has a --exclude-database option (see Release Notes).
Following should work:
pg_dumpall -h mydbname.postgres.database.azure.com -p 5432 -U admin#mydbname --exclude-database=azure* --clean --file=dump.sql
I am trying to learn PostgreSQL tutorial and I keep coming to their error.
Have no idea how to fix it.
It failed with error code 1
Restoring backup on the server 'PostgreSQL 10 (x86) (localhost:5432)'...
Running command:
C:\Program Files (x86)\PostgreSQL\10\bin\pg_restore.exe --host "localhost" --port "5432" --username "postgres" --no-password --dbname "dvdrental" --verbose "C:\\Users\\tbui106\\Desktop\\_SQL\\DVDREN~1.TAR"
pg_restore: [archiver] input file does not appear to be a valid archive
Can someone help? Been on this for hours!
I am running ubuntu 14.04. while backing up a database on postgreSQL i am following error:
/usr/bin/pg_dump --host 127.0.0.1 --port 5432 --username "postgres" --no-password --format custom --section pre-data --section data --section post-data --verbose --file "/home/naveen/consumerDB/CONSUMER_DB" "CONSUMER_DB"
pg_dump: server version: 9.4.8; pg_dump version: 9.3.17
pg_dump: aborting because of server version mismatch
Process returned exit code 1.
Can anyone please help. I tried many other stack overflow links but nothing seems to be working.
The error message seems fairly clear. pg_dump for PostgreSQL 9.3 won't dump a PostgreSQL 9.4 database. Maybe you need to run pg_dump from PostgreSQL 9.4?
If you installed both from packages you'll be using pg_wrapper and should use Debian/Ubuntu's update-alternatives to change pg_dump to point to 9.4's pg_dump. Or run it via the direct path to the actual binary.
See also https://help.ubuntu.com/community/PostgreSQL
Solved: I added .pgpass in the home.
I have the line:
host all all 127.0.0.1/32 md5
in /etc/postgresql/9.4/main/pg_hba.conf but when I run:
pg_dump -U postgres dbase -f dbase.sql
I get:
pg_dump: [archiver (db)] connection to database "dbase" failed:
FATAL: Peer authentication failed for user "postgres"
The Problem you have is, that if u dont define the Host, your system will decide.
explicit add "-h localhost", this will fix it
If adding -h localhost doesn’t work you can try adding -h 127.0.0.1
pg_dump -h 127.0.0.1 -U <username> -d <database_name> -W > bk_name.sql
I encountered this issue when working on a PostgreSQL database on Ubuntu 20.04.
All the PostgreSQL configuration was all good and they have been working fine.
The issue was that I mistakenly modified the ownership of the PostgreSQL files and all other files on the server to a user called deploy.
So each time I try to run the pg_dump operation it fails with the error:
pg_dump: [archiver (db)] connection to database "dbase" failed:
FATAL: Peer authentication failed for user "postgres"
Here's how I solved it:
I installed and set up another PostgreSQL database server on a new VPS.
Next, I made a backup of the PostgreSQL data directory in the old server:
sudo cp /var/lib/postgresql/12/main /var/lib/postgresql/12/main.bk
And copied the backup into the new server and then replaced PostgreSQL data directory in the new server with it. That is I moved out the PostgreSQL data directory in the new server and copied the PostgreSQL data directory backup of the old one into it. You may need to switch to the PostgreSQL user (sudo -u postgres -i) at some point to perform some operation:
sudo systemctl stop postgresql
sudo mv /home/your-username/main.bk /var/lib/postgresql/12/main
sudo -u postgres -i
sudo mv /var/lib/postgresql/12/main /var/lib/postgresql/12/main.bk2
sudo mv /var/lib/postgresql/12/main.bk /var/lib/postgresql/12/main
Finally, I restarted the PostgreSQL database server in the new server:
sudo systemctl restart postgresql
This time when I tried running the pg_dump operation in the new server, it worked fine.
That's all.
I hope this helps