Question

I want to import 'prod.sql' file to database 'd_p_d' for 'postgres' user

postgres=# \l
 d_p_d                 | postgres | UTF8     | en_IN   | en_IN | 
 postgres              | postgres | UTF8     | en_IN   | en_IN | 
 template0             | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
                       |          |          |         |       | postgres=CTc/postgres
 template1             | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
                       |          |          |         |       | postgres=CTc/postgres


postgres=# \du
 postgres  | Superuser, Create role, Create DB, Replication | {}

The error:

postgres=# \i /home/pallavsharma/prod.sql
/home/pallavsharma/prod.sql: Permission denied

also

postgres=# \i /var/dump/prod.sql
/var/dump/prod.sql: Permission denied
Was it helpful?

Solution

The solution is simple CHANGE OWNER of the file prod.sql by following command :

pallavsharma@smartbuzz-G41M-Combo:/var/dump$ sudo chown postgres prod.sql
[sudo] password for pallavsharma: 

Then simply import the db :

postgres=# \i /var/dump/prod.sql

Thats it, it worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top