this is my problem:
myname@ubuntu:~$ sudo su postgres -c "psql template1" Password: psql (9.1.6) Type "help" for help. template1=# \i /create.sql /create.sql: Permission denied
I have this problem even when the file is on the Desktop.
when I copy the text of create.sql and paste it there it works.
using UBUNTU 12.10, postgresql 9.1
Thank you for the help.
The problem is that you’ve launched
psqlas the userpostgresand you haven’t granted thepostgresuser permission to read the SQL file. You’ll need to give it permission. The simplest way is to grant world read rights:You can change the default permissions assigned to files by altering your
umask; search for more information. Some programs rather annoyingly ignore theumaskand set restrictive file permissions anyway, so you always need to know how to grant permissions. Seeman chmodandman chown.BTW, you’re using a very convoluted method for launching
psqlas thepostgresuser. This’ll do just fine:Note that
/create.sqlspecifies a file namedcreate.sqlin root of the file system (/). I doubt this is what you intended.You probably want to specify it as a relative path (without the leading
/) if it’s in your home directory, like:or if it’s on the desktop and you’ve started
psqlin your home directory: