I am trying to restore a schema on a remote server using the psql console in pgAdmin and an sql dump file. I receive the following error:
user=> \i file.sql
file.sql: No such file or directory
I can't seem to print the directory listings due to lacking superuser privileges.
Is there a way to identify or print the current working directory in psql console? What is the default directory?
Type the command \l in the psql command-line interface to display a list of all the databases on your Postgres server.
Typing in the command \! pwd will print the current working directory in psql. To change working directory use command \cd <path>; replace <path> with desired path. Eg. Running command \cd /run/mount will change the current working directory to /run/mount.
Everyone assumes that because you are using postgres that you must be running Linux. Well, postgres is now becoming a very popular DBMS on Windows 10. In Windows 10, in a psql command prompt type "! dir" to print the current working directory. To change directories in the Windows 10 psql client, "\cd /users/yourlogin".
To print the current working directory in CMD, run the cd command without specifying the path or parameters. As an alternative, you can use the chdir command to print the current directory. The cd command is short for change directory, and it is the command we use to navigate in the command prompt.
Also, psql only prints the result of the last SQL command in the string. This is different from the behavior when the same string is read from a file or fed to psql 's standard input, because then psql sends each SQL command separately. Because of this behavior, putting more than one SQL command in a single -c string often has unexpected results.
Typing in the command \! pwd
will print the current working directory in psql.
To change working directory use command \cd <path>
; replace <path>
with desired path. Eg. Running command \cd /run/mount
will change the current working directory to /run/mount
. Try changing the your working directory to that containing the file which you want to run and then use \i
meta command as you did earlier. It will definitely work.
I am shocked that no one answered the question directly in over 2 years. Everyone assumes that because you are using postgres that you must be running Linux. Well, postgres is now becoming a very popular DBMS on Windows 10.
In Windows 10, in a psql command prompt type "! dir" to print the current working directory.
To change directories in the Windows 10 psql client, "\cd /users/yourlogin".
The psql client is a unix shell running on Windows, so it is a mix of unix and dos syntax commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With