Reputation:
when in tried run sql file in psql shell...
give "No such file or directory" error!
$ ls
config.sql config.yaml
$ sudo -i -u postgres psql
postgres=# \i config.sql
config.sql: No such file or directory
thanks for your reply!
-i => goes to user's home directory!
as result ./config.sql address is incorrect!
just use
$ psql -U <user_name>
postgres=# \i config.sql
Upvotes: 2
Views: 3222
Reputation: 247625
man sudo
tells you:
-i
,--login
Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as
.profile
,.bash_profile
or.login
will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell's-c
option.
In particular, that will set your current working directory to the home directory of user postgres
.
If you want to avoid that, don't use '-i'.
Upvotes: 1