title: Postgres / Postgis - Dump and restore to new server with different user
body: <p>I search for a while to find this answer but with no luck. </p>
  
  <p>The situation:</p>
  
  <p>I have Postgresql currently running on my production environment. I am preparing to scale my database and move it to a large server instance. I made the mistake of setting up the initial database with the postgres user who has all permissions, and I would like the new database to be controlled by a custom user I have created. ie The current database's owner is <code>postgres</code>, and I want the new database owner to be <code>pooper</code>.</p>
  
  <p>To dump, I am running:</p>
  
  <p><code>pg_dump -d database_name &gt; database_name.sql</code></p>
  
  <p>To restore on separate machine, I am running:</p>
  
  <p><code>psql database_name &lt; database_name.sql</code></p>
  
  <p>If the user is the same, ie both <code>postgres</code>, then it will work just fine, but when switching users, my app does not load correctly. Is there a secret to the madness. Nothing stood out to me.</p>
  
  <p>My system:</p>
  
  <ul>
  <li>Debian Wheezy</li>
  <li>Postgresql 9.1</li>
  <li>Postgis Extension </li>
  </ul>