title: How to Force Postgresql User Login with Password
body: <p>All I did is in my <strong>local</strong> machine(Mac OS).<br/><br/>
  After installing the postgresql, I created a user named poet with password, then created a database named poems and the database's owner is poet.<br/><br/>
  What I am curious is that I can log into poems with poet without password.<br/><br/>
  The command is <code>psql -U poet -d poems</code>.
  Then what's the usage of the password?<br/><br/>
  I know that I can add -W to get the password prompt <code>psql -U poet -d poems -W</code>, but I can still log in even with a wrong password!<br/><br/>
  Then I modify the config file(/usr/local/var/postgres/pg_hba.conf) like below:<br/><br/></p>
  
  <pre class="lang-js prettyprint-override"><code># "local" is for Unix domain socket connections only
  #local   all             all                                     trust
  local   all             all                                     password
  # IPv4 local connections:
  #host    all             all             127.0.0.1/32            trust
  host    all             all             127.0.0.1/32            password
  # IPv6 local connections:
  #host    all             all             ::1/128                 trust
  host    all             all             ::1/128                 password
  </code></pre>
  
  
  
  <p>And restart the server, I still don't need to provide the password to log into the database.<br/></p>
  
  <p>Can someone tell how to force the server to verify the correctness of login password?</p>