Home Ask Login Register

Developers Planet

Your answer is one click away!

Yadu February 2016

postgresql csv file import

When I try to load a csv file into postgresql. I use the following command.

CREATE TABLE population(
    country char(80),
    year integer,
    population integer

COPY population FROM '/Users/chittampalliyashaswini/Desktop/population.csv'
           DELIMITER ',' CSV HEADER;

Then I get the following error.

ERROR: could not open file "/Users/chittampalliyashaswini/Desktop/population.csv" for reading: Permission denied


Eduardo February 2016

The message is clear, the user postgresql is running under has no permission to read the file. You can move it to /tmp and/or fix the permissions on the path. I typically switch to the postgres user and run a less to check.

If it is a one time thing, I suggest you simply move it to /tmp/ and use that path.

Post Status

Asked in February 2016
Viewed 1,856 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life