title: Error: failed to connect to database: password authentication failed in Rust
body: <p>I am trying to connect to database in Rust using <code>sqlx</code> crate and Postgres database.</p>
  <p><code>main.rs</code>:</p>
  <pre><code>use dotenv;
  use sqlx::Pool;
  use sqlx::PgPool;
  use sqlx::query;
  
  #[async_std::main]
  async fn main() -&gt; Result&lt;(), Error&gt; {
      dotenv::dotenv().ok();
      pretty_env_logger::init();
      let url = std::env::var(&quot;DATABASE_URL&quot;).unwrap();
      dbg!(url);
  
      let db_url = std::env::var(&quot;DATABASE_URL&quot;)?;
      let db_pool: PgPool = Pool::new(&amp;db_url).await?;
  
      let rows = query!(&quot;select 1 as one&quot;).fetch_one(&amp;db_pool).await?;
      dbg!(rows);
  
      let mut app = tide::new();
      app.at(&quot;/&quot;).get(|_| async move {Ok(&quot;Hello Rustacean!&quot;)});
      app.listen(&quot;127.0.0.1:8080&quot;).await?;
  
      Ok(())
  }
  
  #[derive(thiserror::Error, Debug)]
  enum Error {
      #[error(transparent)]
      DbError(#[from] sqlx::Error),
  
      #[error(transparent)]
      IoError(#[from] std::io::Error),
  
      #[error(transparent)]
      VarError(#[from] std::env::VarError),
  }
  </code></pre>
  <p>Here is my <code>.env</code> file:</p>
  <pre><code>DATABASE_URL=postgres://localhost/twitter
  RUST_LOG=trace
  </code></pre>
  <p>Error log:</p>
  <pre><code>error: failed to connect to database: password authentication failed for user &quot;ayman&quot;
    --&gt; src/main.rs:19:16
     |
  19 |     let rows = query!(&quot;select 1 as one&quot;).fetch_one(&amp;db_pool).await?;
     |                ^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
  
  error: aborting due to previous error
  
  error: could not compile `backend`.
  </code></pre>
  <p>Note:</p>
  <ol>
  <li>There exists a database called <code>twitter</code>.</li>
  <li>I have include <code>macros</code> for sqlx's dependency</li>
  </ol>
  <pre><code>sqlx = {version=&quot;0.3.5&quot;, features = [&quot;runtime-async-std&quot;, &quot;macros&quot;, &quot;chrono&quot;, &quot;json&quot;, &quot;postgres&quot;, &quot;uuid&quot;]}
  </code></pre>
  <p>Am I missing some level of authentication for connecting to database? I could not find it in docs for <code>sqlx::Query</code> <a href="https://docs.rs/sqlx/0.3.5/sqlx/macro.query.html" rel="nofollow noreferrer">macro</a></p>