title: Attempt to Connect to MySQL Through PHP Throws Error
body: <p>I'm attempting to use PHP to make a connection to a MySQL database as part of a website, and repeatedly getting two errors:</p>
  
  <blockquote>
    <p>Warning: mysqli_connect(): (HY000/1698): Access denied for user
    'root'@'localhost' in /var/www/html/file.php on line 12</p>
    
    <p>Fatal error: Uncaught Error: Call to a member function query() on
    boolean in /var/www/html/file.php:20 Stack trace: #0 {main} thrown in
    /var/www/html/file.php on line 20</p>
  </blockquote>
  
  <p>My code is just connecting and one query:</p>
  
  <pre><code>&lt;?php
  //Error reporting
  ini_set('display_errors', 1);
  error_reporting(~0);
  //Server data
  $servername = "localhost";
  $username = "root";
  $password = "password";
  $dbname = "database";
  $tblname = "table";
  //Connection
  $connect = mysqli_connect($servername, $username, $password, $dbname, null);
  //Query
  $sql = 'SELECT column1 FROM table';
  //Send query
  $result = $connect-&gt;query($sql);
  $connect-&gt;close();
  ?&gt;
  </code></pre>
  
  <p>Line 12 refers to <code>$connect = mysqli_connect($servername, $username, $password, $dbname, null);</code> and line 20 refers to <code>$result = $connect-&gt;query($sql);</code></p>
  
  <p>I've done a lot of searching for what might be the matter; if anyone has some insight, I'd greatly appreciate it. Thanks.</p>
  
  <p>EDIT: I needed to setup a new user, problem is solved. Thanks all.</p>