title: Postgres: COPY TO error
body: <p>I need help turning my Postgres table into a CSV file. First, I type </p>
  
  <pre><code>sudo su postgres (then I enter my password)
  psql -d postgres -U postgres
  </code></pre>
  
  <p>The terminal looks like:</p>
  
  <pre><code>postgres=#
  </code></pre>
  
  <p>I typed in the COPY TO command to try to create a .csv file with all the information in my table, but I get an error:</p>
  
  <pre><code>postgres=# COPY venues TO '/usr/file.csv';
  ERROR:  could not open file "/usr/file.csv" for writing: Permission denied
  </code></pre>
  
  <p>I also tried using the \copy command, but I get:</p>
  
  <pre><code>postgres=# \COPY venues TO '/usr/file.csv';
  /usr/file.csv: Permission denied
  </code></pre>
  
  <p>I read a couple answers that said that I might not have permission to write in a certain directory. Is this true?</p>
  
  <p>Also, in postgres, the schema lists my_name as the owner of the table I am trying to export information from (venues). However, this is when I am logged in as a postgres user, and I am only able to access the table when I am a logged is as a postgres user.</p>
  
  <p>When I log into postgres by simply typing "psql," I get:</p>
  
  <pre><code>my_name=&gt;
  </code></pre>
  
  <p>and when I type the command "\d" to see the tables under this user, I do not see the venues table listed.
  Can someone please help me with this issue? Thank you in advance.</p>