postgresql permissions failure to copy csv data

netsuke

in my experience, this failure have multiple possibility and solution

1. path must absolute (possibility)


-- this code will error

psql > COPY your_table FROM 'folder/your.csv ' DELIMITER ',' HEADER;

-- this code will run

psql > COPY your_table FROM '/tmp/folder/your.csv ' DELIMITER ',' HEADER;

 

path information

 

2. copy to folder /tmp (solution)


# copy to folder /tmp

cp your.csv /tmp

# just make sure it can be read

chmod 777 /tmp/your.csv

# then run psql copy command

 

 

3. add postgres user to group which can read the file


# example the group user can read write execute file in folder is user/group vboxsf / youruser

# add postgres to vboxsf groups

$ sudo usermod -a -G vboxsf postgres

# restart postgres service

$ sudo service postgresql restart

# then run psql copy command

 

myserver config

image from

Published by

G3n1k

just to remember what i had known :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s