“[Errno 2] No such file or directory” when trying

2020-03-25 11:01发布

问题:

I have finally managed to get around managing to manually set "PostgreSQL Binary Path" in preferences (why should the user have to do this when it wasn't necessary in pgAdmin3?).

Though to be honest, I have no idea what is meant with the second path field called "EDB Advanced Server Binary Path". But I get no more error message concerning that so I assume it is o.k. to leave that empty.

Now I am stuck on the next step.

When trying to backup the database I have to enter a filename. No matter what I do here, I keep getting this error:

[Errno 2] No such file or directory

Well, it can not be that I have to create a file before it is created by pgAdmin, can it?

What could I be doing wrong?

Alex


update: answering to @n33rma here are the print screens:

回答1:

I just updated to pgAdmin v4.1 and this solved the issue :-) Thanks all for helping!



回答2:

I solved the problem through the command line.

If we use a previous format, it has the same response as you had:

$ pg_restore -d <DBNAME> --username=postgres g=<FILENAME> 
pg_restore: [archiver] could not open input file "g=<FILENAME>": No such file or directory

If we change the last param, it works properly:

$ pg_restore -d <DBNAME> --username=postgres <FILENAME>

I suppose the GUI-command changed in v4, but the console pg_restore is not.



回答3:

You need to give absolute path with the file name to sql file like below.

Windows

C:/test/test.sql

Linux

/u01/test.sql



回答4:

Enter only a filename, no path, because pgadmin puts the backup in its own directory, specifically, in ~/.pgadmin/storage/(user).



回答5:

I suspect that path for "PostgreSQL Binary Path" is not set properly in pgAdmin4.

pgAdmin4 is Web application and pgAdmin3 is Desktop application, So pgAdmin4 needs to know path of utilities like pg_dump & pg_restore binaries so that it can execute them.

In pgAdmin4 Goto: File > Preferences > Paths > Binary paths > PostgreSQL Binary Path

If you are using Windows than provide path like, C:\Program Files\PostgreSQL\9.6\bin

If you are using Linux than provide path like, /opt/PostgreSQL/9.5/bin

user@mint:/opt/PostgreSQL/9.5/bin$ lsh pg_du* pg_res*
-rwxr-xr-x 1 xxx xxx 150K Sep  2  2015 pg_restore
-rwxr-xr-x 1 xxx xxx  49K Sep  2  2015 pg_resetxlog
-rwxr-xr-x 1 xxx xxx  83K Sep  2  2015 pg_dumpall
-rwxr-xr-x 1 xxx xxx 364K Sep  2  2015 pg_dump


回答6:

On MacOS 10.11 and using postgres.app I resolved it this way:



标签: pgadmin-4