title: Restore database from pg_dump syntax errors
body: <p>all I am trying to restore my db from pg_dump that I got from my server. I know there are plenty similar question, I tried what was suggested but still can not resolve my issue.
  I created my pg_dump via this command:</p>
  
  <pre class="lang-none prettyprint-override"><code>pg_dump name_of_database &gt; name_of_backup_file
  </code></pre>
  
  <p>Then I create new db:</p>
  
  <pre class="lang-none prettyprint-override"><code>createdb -T template0 restored_database
  </code></pre>
  
  <p>Then I restore using this command:</p>
  
  <pre class="lang-none prettyprint-override"><code>psql -1 -f name_of_backup_file.sql restored_database
  </code></pre>
  
  <p>It runs and then I got different syntax errors, for example:</p>
  
  <pre class="lang-none prettyprint-override"><code>psql:nurate_pg_dump.sql:505: invalid command \nWatch
  Query buffer reset (cleared).
  psql:nurate_pg_dump.sql:512: invalid command \nThe
  psql:nurate_pg_dump.sql:513: invalid command \N
  psql:nurate_pg_dump.sql:4098: ERROR:  syntax error at or near "9"
  LINE 1: 9 the course is not difficult, but Zauresh Atakhanova is not...
  </code></pre>
  
  <p>I believe since I made pg_dump from the same server, and try to restore it there nothing changed in my server setup, or version of  postgres, so I think my db should restore correctly. How can I resolve these syntax errors?</p>
  
  <p>EDIT: Ok, the problem is not with the syntax:</p>
  
  
  
  <blockquote>
    <p>CREATE EXTENSION<br>
       ERROR:  must be owner of extension plpgsql</p>
  </blockquote>
  
  <p>This error is thrown at this line:</p>
  
  <pre><code>CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
  </code></pre>