title: Export everything from PostgreSQL
body: <p>I want to export everything(users, roles, object definitions, data) from my PostgreSQL and restore it into another server. How can I do that?</p>
  
  <p>I try to use</p>
  
  <pre><code>pg_dumpall -U postgres -g &gt; out.sql
  </code></pre>
  
  <p>but file <strong>out.sql</strong> is empty. Can someone explain me why this happens?</p>
  
  <p>When I try:</p>
  
  <pre><code>pg_dumpall -U postgres &gt; out.sql
  </code></pre>
  
  <p>PostgreSQL just didn't want to accept password for "postgres".</p>
  
  <p>I prefer to do this job from (windows) command line(it is not problem and with linux command, I can translate them). And if there is nice pgAdmin way to do it, I will happy to learn it, too.</p>
  
  <h2>P.S: My password for "postgres" is correct (I try to login with "psql -U postgres" and there is no problem)</h2>
  
  <p>Update: I try with user different than "postgres"(in this case <strong>rsmn</strong>):</p>
  
  <pre><code>pg_dumpall -U rsmn &gt; out.sql
  </code></pre>
  
  <p>I have following error:</p>
  
  <blockquote>
    <p>pg_dumpall: query failed: ERROR: permission dneied for relation
    pg_authid pg_dumpall: query was: SELECT oid, rolname, rolsuper,
    rolinherit, rolcreaterole, rolcreatedb, rolcanlogin, rolconnlimit,
    rolpassword, rolvalidunil, rolreplication, rolbypassrls,
    pg_catalog.shobj_description(oid, 'pg_authid') as rolcomment, rolname
    = current_user as is_current_user FROM pg_authid WHERE rolname !~ '^pg_' ORDER BY 2</p>
  </blockquote>
  
  <p>User privileges(This user is only one beside "postgres"):
  <a href="https://i.stack.imgur.com/EV99D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EV99D.png" alt="enter image description here"></a></p>